home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d966.lha / UChessSrc / UChessSrc.lha / main.c < prev    next >
C/C++ Source or Header  |  1994-02-09  |  146KB  |  5,392 lines

  1. /*#define EIGHT_BIT_SCREEN 1 */
  2.  
  3. /* main.c - C source for GNU CHESS
  4.  *
  5.  * Copyright (c) 1988,1989,1990 John Stanback
  6.  * Copyright (c) 1992 Free Software Foundation
  7.  *
  8.  * This file is part of GNU CHESS.
  9.  *
  10.  * GNU Chess is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2, or (at your option)
  13.  * any later version.
  14.  *
  15.  * GNU Chess is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with GNU Chess; see the file COPYING.  If not, write to
  22.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25. int __aligned CheckIllegal = 0;
  26. extern int IllegalMove;
  27. #include "version.h"
  28. #include "gnuchess.h"
  29. #include <signal.h>
  30. #include <ctype.h>
  31.  
  32. #ifdef AMIGA
  33. #define EXCLUDE_PATT 0xffffff00L
  34. #define __USE_SYSBASE
  35. #include <exec/types.h>
  36. #include <exec/exec.h>
  37. #include <proto/exec.h>
  38. #include <proto/dos.h>
  39. #include <proto/graphics.h>
  40. #include <graphics/gfxbase.h>
  41. #include <proto/intuition.h>
  42. #include <utility/tagitem.h>
  43. #include <graphics/modeid.h>
  44. #include <lhlib.h>
  45. #include <libraries/asl.h>
  46. #include <proto/icon.h>
  47. #include <proto/asl.h>
  48. #include <workbench/startup.h>
  49. #include <workbench/workbench.h>
  50.  
  51.  
  52. #define mySetABPenDrMd(a,b,c,d) if (gfxversion > 38) {SetABPenDrMd(a,b,c,d);} else {SetAPen(a,b);SetDrMd(a,d);}
  53.  
  54. struct __iobuf __iob[1];
  55. #define LN2 693147 /* .693147 */
  56. #define LOGE_34 3526361 /* log2(34) = ln(34)/ln(2) = 5.087463 */
  57. #define LOGE_16 2772589 /* ln(16) = */
  58. void calc_pgm_rating(void);
  59. void DoEasy(void);
  60. void DoIntermediate(void);
  61. void DoAdvanced(void);
  62.  
  63.  
  64. /* this table index ln(2)*1e6 - ln(1202)*1e6 by 6's */
  65. /* so take (#secs - 2)/6 for index into this table */
  66.  
  67. long __aligned OrigResponse;
  68. int __aligned __far log_e[]={
  69. 693147, 2079442, 2639057, 2995732, 3258097, 3465736, 3637586, 3784190, 
  70. 3912023, 4025352, 4127134, 4219508, 4304065, 4382027, 4454347, 4521789, 
  71. 4584967, 4644391, 4700480, 4753590, 4804021, 4852030, 4897840, 4941642, 
  72. 4983607, 5023881, 5062595, 5099866, 5135798, 5170484, 5204007, 5236442, 
  73. 5267858, 5298317, 5327876, 5356586, 5384495, 5411646, 5438079, 5463832, 
  74. 5488938, 5513429, 5537334, 5560682, 5583496, 5605802, 5627621, 5648974, 
  75. 5669881, 5690359, 5710427, 5730100, 5749393, 5768321, 5786897, 5805135, 
  76. 5823046, 5840642, 5857933, 5874931, 5891644, 5908083, 5924256, 5940171, 
  77. 5955837, 5971262, 5986452, 6001415, 6016157, 6030685, 6045005, 6059123, 
  78. 6073045, 6086775, 6100319, 6113682, 6126869, 6139885, 6152733, 6165418, 
  79. 6177944, 6190315, 6202536, 6214608, 6226537, 6238325, 6249975, 6261492, 
  80. 6272877, 6284134, 6295266, 6306275, 6317165, 6327937, 6338594, 6349139, 
  81. 6359574, 6369901, 6380123, 6390241, 6400257, 6410175, 6419995, 6429719, 
  82. 6439350, 6448889, 6458338, 6467699, 6476972, 6486161, 6495266, 6504288, 
  83. 6513230, 6522093, 6530878, 6539586, 6548219, 6556778, 6565265, 6573680, 
  84. 6582025, 6590301, 6598509, 6606650, 6614726, 6622736, 6630683, 6638568, 
  85. 6646391, 6654153, 6661855, 6669498, 6677083, 6684612, 6692084, 6699500, 
  86. 6706862, 6714171, 6721426, 6728629, 6735780, 6742881, 6749931, 6756932, 
  87. 6763885, 6770789, 6777647, 6784457, 6791221, 6797940, 6804615, 6811244, 
  88. 6817831, 6824374, 6830874, 6837333, 6843750, 6850126, 6856462, 6862758, 
  89. 6869014, 6875232, 6881411, 6887553, 6893656, 6899723, 6905753, 6911747, 
  90. 6917706, 6923629, 6929517, 6935370, 6941190, 6946976, 6952729, 6958448, 
  91. 6964136, 6969791, 6975414, 6981006, 6986566, 6992096, 6997596, 7003065, 
  92. 7008505, 7013915, 7019297, 7024649, 7029973, 7035269, 7040536, 7045777, 
  93. 7050989, 7056175, 7061334, 7066467, 7071573, 7076654, 7081709, 7086738, 
  94. 7091742};
  95.  
  96.  
  97. /* Structure for transparent images */
  98.  
  99. #define PTRHEIGHT 55
  100.  
  101. #define BLANKDATA 0xffff
  102.  
  103. int __aligned lastpiece=BLANKDATA;
  104.  
  105. void Undo(void);
  106.  
  107. char __aligned __far vstring[64]={AVSTR};
  108.  
  109. long __far __aligned piecechar[12]={'p','n','b','r','q','k',
  110.                           'P','N','B','R','Q','K'};
  111. char __far __aligned oldboard[8][8];
  112.  
  113.  
  114. ULONG __far __aligned bpen;
  115. int __aligned PlayMode = 2;
  116. int __aligned global_tmp_score=0;
  117. int __aligned previous_score=0;
  118. extern short int ISZERO;
  119. extern int thinkahead;
  120. unsigned long int __aligned next = 1;
  121. int __aligned doswap=0;
  122. int __aligned doundo=0;
  123. int __aligned doauto=0;
  124. int __aligned gfxversion=0L;
  125. int __aligned v15Khz=0L;
  126. int __aligned teston=0;
  127. struct TagItem __aligned __far myTagList[4] = {
  128. {SA_DisplayID,VGAPRODUCT_KEY},
  129. {0,0}
  130. };
  131.  
  132. int __aligned MoveNowOK=0;
  133.  
  134. #define WINDOWSIGNAL (1L<<(wG->UserPort->mp_SigBit))
  135. ULONG __aligned globalsignalset=0L;
  136.  
  137. int __aligned Super72=0;
  138. int __aligned procpri=3;
  139. struct Process __aligned *myproc;
  140.  
  141. int __aligned __far ResignOffered=0;
  142. ULONG __far __aligned tmppal[4];
  143.  
  144. inline void TimeCalc (void);
  145.  
  146.  
  147. int __far __aligned FasterDisplay=0;
  148. int __aligned trying_again=0;
  149. int __aligned SupervisorMode=0;
  150. int __aligned MenuStripSet = 0;
  151. int __aligned GlobalTgtDepth=3;
  152.  
  153. UWORD chip myPointer[]={
  154. 0,0,
  155. 31744,0,
  156. 4096,0,
  157. 4096,0,
  158. 4096,0,
  159. 4096,0,
  160. 5120,0,
  161. 5120,0,
  162. 1024,0,
  163. 1920,0,
  164. 1152,0,
  165. 1152,0,
  166. 1152,0,
  167. 256,0,
  168. 0,0,
  169. 768,0,
  170. 256,0,
  171. 256,0,
  172. 256,0,
  173. 896,0,
  174. 0,0,
  175. 896,0,
  176. 576,0,
  177. 576,0,
  178. 576,0,
  179. 576,0,
  180. 0,0,
  181. 512,0,
  182. 512,0,
  183. 576,0,
  184. 640,0,
  185. 896,0,
  186. 640,0,
  187. 576,0,
  188. 0,0,
  189. 256,0,
  190. 0,0,
  191. 768,0,
  192. 256,0,
  193. 256,0,
  194. 256,0,
  195. 896,0,
  196. 0,0,
  197. 0,0,
  198. 896,0,
  199. 576,0,
  200. 576,0,
  201. 576,0,
  202. 576,0,
  203. 0,0,
  204. 960,0,
  205. 576,0,
  206. 576,0,
  207. 960,0,
  208. 64,0,
  209. 960,0,
  210. 0,0
  211. };
  212.  
  213.  
  214. struct TransImage
  215. {
  216.     struct Image *ti_IM;    /* The plain image */
  217.     struct BitMap *ti_sBM;    /* Shadow bitmap */
  218.     struct RastPort *ti_sRP;    /* Shadow rastport */
  219.     struct BitMap ti_BM;    /* Image bitmap */
  220.     struct RastPort ti_RP;    /* Image rastport */
  221. };
  222.  
  223. struct Image __aligned BobImage;
  224.  
  225. struct TransImage __aligned *BobTransImage;
  226.  
  227. struct TransImage *AllocTransImage (struct Image * im);
  228. VOID FreeTransImage (struct TransImage * ti);
  229. VOID ClipBlitTrans (struct RastPort *, WORD, WORD, struct RastPort *, WORD, WORD, WORD, WORD, struct RastPort *);
  230. struct BitMap *AllocShadowBM (UWORD, UWORD, UWORD);
  231. VOID FreeShadowBM (struct BitMap *);
  232. struct RastPort *AllocShadowRP (struct BitMap *);
  233. VOID FreeShadowRP (struct RastPort *);
  234. long __aligned OrigCol,OrigRow,DestCol,DestRow;
  235.  
  236.  
  237. #define TDEPTH 4
  238. #define THEIGHT 400 /* tmp ht */
  239. #define TBLOCKPEN 4 /* was 9 */
  240.  
  241. #ifdef EIGHT_BIT_SCREEN
  242. int __aligned DEPTH=8;
  243. #ifdef MANYP
  244. int __aligned HEIGHT=480;
  245. int __aligned USERBOX=168;
  246. int __aligned COMPUTERBOX=60;
  247. int __aligned BACKGNDTEXTCOLOR=0xe0; /* for 256 use 0xe0 */
  248. int __aligned BOBHEIGHT=55; /* 55 for 480 screens */
  249. int __aligned ROW8=24; /* 24 for 480 screens */
  250. int __aligned MBLOCKPEN=251;
  251. #endif
  252. #else
  253. int __aligned DEPTH=4;
  254. #endif
  255.  
  256. int __aligned TCadd = 0;
  257. int __aligned thinking2=0; /* look for move now menu selection in elasped time when set */
  258. int __aligned TIMEYCOORD1=100;
  259. int __aligned TIMEYCOORD2=192;
  260. int __aligned SYSBOXLEN=86;
  261. int __aligned HEIGHT=400;
  262. int __aligned USERBOX=140;
  263. int __aligned SYSTEMBOX=233;
  264. int __aligned COMPUTERBOX=50;
  265. int __aligned BACKGNDTEXTCOLOR=15; /* for 256 use 0xe0 */
  266. int __aligned BOBHEIGHT=46; /* 55 for 480 screens */
  267. int __aligned ROW8=20; /* 24 for 480 screens */
  268. int __aligned MBLOCKPEN=9;
  269.  
  270. #define MENUBARHT 11
  271. #define WIDTH 640
  272. #define VIEWMODES (HIRES|LACE)
  273.  
  274. int __aligned BOBDEPTH=TDEPTH;
  275. #define BOBWIDTH 64 /* only 59 pixels are really used, rest are tranparent */
  276. #define BOBWIDINW 4
  277. #define BOBSIZE (BOBHEIGHT*BOBDEPTH*BOBWIDINW*sizeof(WORD))
  278. #define BOBBLOCKSIZE ((BOBSIZE)+(BOBWIDINW*sizeof(WORD)*(BOBHEIGHT+2))+(BOBWIDINW*sizeof(WORD)))
  279. #define BOBLW ((BOBBLOCKSIZE)/4)
  280. #define BOBMEMASK 0
  281. #define BOBHITMASK 0
  282. int __aligned BOBPLANEPICK=0xf; /* if 16 colors should be 0xf if 256 should be 0xff */
  283. #define BOBPLANEONOFF 0x0
  284.  
  285. #define SQUAREWIDTH 59
  286. #define ROUNDEDSQUAREWIDTH 64
  287. #define SQUAREHEIGHT BOBHEIGHT
  288. #define COLA (16)
  289. #define COLB (16+SQUAREWIDTH)
  290. #define COLC (16+SQUAREWIDTH*2)
  291. #define COLD (16+SQUAREWIDTH*3)
  292. #define COLE (16+SQUAREWIDTH*4)
  293. #define COLF (16+SQUAREWIDTH*5)
  294. #define COLG (16+SQUAREWIDTH*6)
  295. #define COLH (16+SQUAREWIDTH*7)
  296. #define ROW7 (ROW8+SQUAREHEIGHT)
  297. #define ROW6 (ROW8+SQUAREHEIGHT*2)
  298. #define ROW5 (ROW8+SQUAREHEIGHT*3)
  299. #define ROW4 (ROW8+SQUAREHEIGHT*4)
  300. #define ROW3 (ROW8+SQUAREHEIGHT*5)
  301. #define ROW2 (ROW8+SQUAREHEIGHT*6)
  302. #define ROW1 (ROW8+SQUAREHEIGHT*7)
  303.  
  304.  
  305. UWORD __aligned *BlankImageData;
  306.  
  307. UWORD __far __aligned *WhiteImageData[6];
  308. UWORD __far __aligned *BlackImageData[6];
  309.  
  310. void LoadBobImage(long);
  311.  
  312. long __far __aligned ColArray[8]={COLA,COLB,COLC,COLD,COLE,COLF,COLG,COLH};
  313. long __far __aligned RowArray[8];
  314.  
  315. struct VSprite __aligned *SpriteHead;
  316. struct VSprite __aligned *SpriteTail;
  317.  
  318. struct GelsInfo __aligned *myGelsInfo;
  319. struct VSprite __aligned *BobVSprite;
  320. struct Bob __aligned *TheBob;
  321.  
  322. struct BitMap __aligned *WhiteBitMap,*BlackBitMap;
  323.  
  324. struct TextFont __aligned *myTextFont;
  325.  
  326. extern struct GfxBase __aligned *Gfxbase;
  327. long __aligned __stack=50000L;
  328. ULONG tt;
  329. struct RastPort __aligned *rpG;
  330. struct ViewPort __aligned *vP;
  331. struct Screen __aligned *sC;
  332. struct Window __aligned *wG;
  333. struct Window __aligned *wGEdit;
  334. unsigned char __far __aligned cookedchar[128]={'~',
  335.                   '1',
  336.                   '2',
  337.                   '3',
  338.                   '4',
  339.                   '5',
  340.                   '6',
  341.                   '7',
  342.                   '8',
  343.                   '9',
  344.                   '0', /* 10 */
  345.                   '-',
  346.                   '=',
  347.                   ' ',
  348.                   ' ',
  349.                   '0',
  350.                   'Q', /* 16 */
  351.                   'W',
  352.                   'E',
  353.                   'R',
  354.                   'T', /* 20 */
  355.                   'Y',
  356.                   'U',
  357.                   'I',
  358.                   'O',
  359.                   'P', /* 25 */
  360.                   '[',
  361.                   ']',
  362.                   ' ',
  363.                   '1',
  364.                   '2',
  365.                   '3',
  366.                   'A',
  367.                   'S',
  368.                   'D',
  369.                   'F',
  370.                   'G',
  371.                   'H',
  372.                   'J',
  373.                   'K',
  374.                   'L', /* 40 */
  375.                   ':',
  376.                   '"',
  377.                   13,
  378.                   ' ',
  379.                   '4',
  380.                   '5',
  381.                   '6',
  382.                   ' ',
  383.                   'Z',
  384.                   'X', /* 50 */
  385.                   'C',
  386.                   'V',
  387.                   'B',
  388.                   'N',
  389.                   'M', /* 55 */
  390.                   ',',
  391.                   '.',
  392.                   '/',
  393.                   ' ',
  394.                   '.',
  395.                   '7',
  396.                   '8',
  397.                   '9',
  398.                   ' ',
  399.                   7,
  400.                   8,
  401.                   13,
  402.                   13,
  403.                   27,
  404.                   7
  405. };
  406.  
  407.  
  408.  
  409.  
  410. char __aligned *Orig_PlanePtr;
  411. struct BitMap __aligned *myBitMap;
  412.  
  413. #include "Chess256Palette.c"
  414.  
  415. UWORD __far __aligned myPalette[16]=
  416. {
  417. 0xfbc, 0x632, 0x455, 0x842, 0x549, 0xa53, 0x787, 0xa56, 
  418. 0x967, 0xa85, 0x3ab, 0xaaa, 0xe88, 0xdb8, 0x333, 0xeee
  419. };
  420.  
  421. #ifdef OLDPAL
  422. {
  423. 0x0, 0x222, 0x410, 0x333, 
  424. 0x621, 0x624, 0x952, 0x665, 
  425. 0x974, 0x887, 0xb85, 0xaa9, 
  426. 0xbb7, 0xcc8, 0xcc9, 0xddc};
  427. #endif 
  428.  
  429. struct TextAttr __far __aligned TOPAZ80 = {
  430.     (STRPTR)"topaz.font",
  431.     TOPAZ_EIGHTY,0,0
  432. };
  433.  
  434. SHORT __far __aligned BorderVectors6[] = {
  435.     0,0,
  436.     44,0,
  437.     44,19,
  438.     0,19,
  439.     0,0
  440. };
  441. struct Border __far __aligned Border6 = {
  442.     -1,-1,    /* XY origin relative to container TopLeft */
  443.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  444.     5,    /* number of XY vectors */
  445.     BorderVectors6,    /* pointer to XY vectors */
  446.     NULL    /* next border in list */
  447. };
  448.  
  449. struct IntuiText __far __aligned IText93 = {
  450.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  451.     12,6,    /* XY origin relative to container TopLeft */
  452.     NULL,    /* font pointer or NULL for default */
  453.     "OK",    /* pointer to text */
  454.     NULL    /* next IntuiText structure */
  455. };
  456.  
  457. struct Gadget __far __aligned Gadget9 = {
  458.     NULL,    /* next gadget */
  459.     109,64,    /* origin XY of hit box relative to window TopLeft */
  460.     43,18,    /* hit box width and height */
  461.     NULL,    /* gadget flags */
  462.     RELVERIFY,    /* activation flags */
  463.     BOOLGADGET,    /* gadget type flags */
  464.     (APTR)&Border6,    /* gadget border or image to be rendered */
  465.     NULL,    /* alternate imagery for selection */
  466.     &IText93,    /* first IntuiText structure */
  467.     NULL,    /* gadget mutual-exclude long word */
  468.     NULL,    /* SpecialInfo structure */
  469.     NULL,    /* user-definable data */
  470.     NULL    /* pointer to user-definable data */
  471. };
  472.  
  473. UBYTE __aligned Gadget8SIBuff[8];
  474. struct StringInfo __aligned Gadget8SInfo = {
  475.     Gadget8SIBuff,    /* buffer where text will be edited */
  476.     NULL,    /* optional undo buffer */
  477.     0,    /* character position in buffer */
  478.     5,    /* maximum number of characters to allow */
  479.     0,    /* first displayed character buffer position */
  480.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  481.     0,    /* Rastport of gadget */
  482.     0,    /* initial value for integer gadgets */
  483.     NULL    /* alternate keymap (fill in if you set the flag) */
  484. };
  485.  
  486. SHORT __far __aligned BorderVectors7[] = {
  487.     0,0,
  488.     45,0 /* was 45 */,
  489.     45,14, /* was 17 */
  490.     0,14,
  491.     0,0
  492. };
  493. struct Border __far __aligned Border7 = {
  494.     -1,-1,    /* XY origin relative to container TopLeft */
  495.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  496.     5,    /* number of XY vectors */
  497.     BorderVectors7,    /* pointer to XY vectors */
  498.     NULL    /* next border in list */
  499. };
  500.  
  501. struct Gadget __far __aligned Gadget8 = {
  502.     &Gadget9,    /* next gadget */
  503.     136,32,    /* origin XY of hit box relative to window TopLeft */
  504.     44,16,    /* hit box width and height */
  505.     NULL,    /* gadget flags */
  506.     RELVERIFY,    /* activation flags */
  507.     STRGADGET,    /* gadget type flags */
  508.     (APTR)&Border7,    /* gadget border or image to be rendered */
  509.     NULL,    /* alternate imagery for selection */
  510.     NULL,    /* first IntuiText structure */
  511.     NULL,    /* gadget mutual-exclude long word */
  512.     (APTR)&Gadget8SInfo,    /* SpecialInfo structure */
  513.     NULL,    /* user-definable data */
  514.     NULL    /* pointer to user-definable data */
  515. };
  516.  
  517.  
  518. UBYTE __aligned Gadget6SIBuff[8];
  519. struct StringInfo __aligned Gadget6SInfo = {
  520.     Gadget6SIBuff,    /* buffer where text will be edited */
  521.     NULL,    /* optional undo buffer */
  522.     0,    /* character position in buffer */
  523.     4,    /* maximum number of characters to allow */
  524.     0,    /* first displayed character buffer position */
  525.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  526.     0,    /* Rastport of gadget */
  527.     0,    /* initial value for integer gadgets */
  528.     NULL    /* alternate keymap (fill in if you set the flag) */
  529. };
  530.  
  531. struct Border __far __aligned Border9 = {
  532.     -1,-1,    /* XY origin relative to container TopLeft */
  533.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  534.     5,    /* number of XY vectors */
  535.     BorderVectors7,    /* pointer to XY vectors */
  536.     NULL    /* next border in list */
  537. };
  538.  
  539. struct Gadget __far __aligned Gadget6 = {
  540.     &Gadget8,    /* next gadget */
  541.     14,32,    /* origin XY of hit box relative to window TopLeft */
  542.     44,16,    /* hit box width and height */
  543.     NULL,    /* gadget flags */
  544.     RELVERIFY,    /* activation flags */
  545.     STRGADGET,    /* gadget type flags */
  546.     (APTR)&Border9,    /* gadget border or image to be rendered */
  547.     NULL,    /* alternate imagery for selection */
  548.     NULL,    /* first IntuiText structure */
  549.     NULL,    /* gadget mutual-exclude long word */
  550.     (APTR)&Gadget6SInfo,    /* SpecialInfo structure */
  551.     NULL,    /* user-definable data */
  552.     NULL    /* pointer to user-definable data */
  553. };
  554.  
  555. struct Gadget __far __aligned Gadget6b = {
  556.     &Gadget9,    /* next gadget */
  557.     14,32,    /* origin XY of hit box relative to window TopLeft */
  558.     44,16,    /* hit box width and height */
  559.     NULL,    /* gadget flags */
  560.     RELVERIFY,    /* activation flags */
  561.     STRGADGET,    /* gadget type flags */
  562.     (APTR)&Border9,    /* gadget border or image to be rendered */
  563.     NULL,    /* alternate imagery for selection */
  564.     NULL,    /* first IntuiText structure */
  565.     NULL,    /* gadget mutual-exclude long word */
  566.     (APTR)&Gadget6SInfo,    /* SpecialInfo structure */
  567.     NULL,    /* user-definable data */
  568.     NULL    /* pointer to user-definable data */
  569. };
  570.  
  571.  
  572. /**/
  573.  
  574.  
  575. struct IntuiText __aligned IText47 = {
  576.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  577.     195,36,    /* XY origin relative to container TopLeft */
  578.     NULL,    /* font pointer or NULL for default */
  579.     "Minutes.",    /* pointer to text */
  580.     NULL    /* next IntuiText structure */
  581. };
  582.  
  583. struct IntuiText __far __aligned IText46 = {
  584.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  585.     64,35,    /* XY origin relative to container TopLeft */
  586.     NULL,    /* font pointer or NULL for default */
  587.     "Moves in",    /* pointer to text */
  588.     &IText47    /* next IntuiText structure */
  589. };
  590.  
  591. #define IntuiTextList5 IText46
  592.  
  593. struct NewWindow __far __aligned NewWindowStructure5 = {
  594.     161,23,    /* window XY origin relative to TopLeft of screen */
  595.     270,90,    /* window width and height */
  596.     0,TBLOCKPEN,    /* detail and block pens */
  597.     GADGETUP,    /* IDCMP flags */
  598.     SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  599.     &Gadget6,    /* first gadget in gadget list */
  600.     NULL,    /* custom CHECKMARK imagery */
  601.     "Computer Time Ctrl",    /* window title */
  602.     NULL,    /* custom screen pointer */
  603.     NULL,    /* custom bitmap */
  604.     5,5,    /* minimum width and height */
  605.     0xffff,0xffff,    /* maximum width and height */
  606.     CUSTOMSCREEN    /* destination screen type */
  607. };
  608.  
  609.  
  610. struct ExtNewScreen __far __aligned NewScreenStructure = {
  611.     0,0,    /* screen XY origin relative to View */
  612.     WIDTH,THEIGHT,    /* screen width and height */
  613.     4,    /* screen depth (number of bitplanes) */
  614.     0,TBLOCKPEN,    /* detail and block pens */
  615.     VIEWMODES,    /* display modes for this screen */
  616.     CUSTOMBITMAP|CUSTOMSCREEN,    /* screen type */
  617.     &TOPAZ80,    /* pointer to default screen font */
  618.     VERSTRING,    /* screen title */
  619.     NULL,    /* first in list of custom screen gadgets */
  620.     NULL    /* pointer to custom BitMap structure */
  621. };
  622.  
  623. struct ExtNewScreen __far __aligned NewScreenStructure2 = {
  624.     0,0,    /* screen XY origin relative to View */
  625.     WIDTH,480,    /* screen width and height */
  626.     8,    /* screen depth (number of bitplanes) */
  627.     0,251,    /* detail and block pens */
  628.     VIEWMODES,    /* display modes for this screen */
  629.     CUSTOMSCREEN|SCREENBEHIND,    /* screen type */
  630.     &TOPAZ80,    /* pointer to default screen font */
  631.     " ",    /* screen title */
  632.     NULL,    /* first in list of custom screen gadgets */
  633.     NULL    /* pointer to custom BitMap structure */
  634. };
  635.  
  636.  
  637. struct IntuiText __far __aligned IText37 = {
  638.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  639.     0,0,    /* XY origin relative to container TopLeft */
  640.     &TOPAZ80,    /* font pointer or NULL for default */
  641.     "New Game",    /* pointer to text */
  642.     NULL    /* next IntuiText structure */
  643. };
  644.  
  645. struct IntuiText __far __aligned IText1r = {
  646.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  647.     0,0,    /* XY origin relative to container TopLeft */
  648.     &TOPAZ80,    /* font pointer or NULL for default */
  649.     "Set Depth",    /* pointer to text */
  650.     NULL    /* next IntuiText structure */
  651. };
  652.  
  653. struct MenuItem __aligned MenuItem3r = {
  654.     NULL,    /* next MenuItem structure */
  655.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  656.     72,8,    /* hit box width and height */
  657.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  658.     0,    /* each bit mutually-excludes a same-level Item */
  659.     (APTR)&IText1r,    /* Item render  (IntuiText or Image or NULL) */
  660.     NULL,    /* Select render */
  661.     NULL,    /* alternate command-key */
  662.     NULL,    /* SubItem list */
  663.     MENUNULL    /* filled in by Intuition for drag selections */
  664. };
  665.  
  666. struct IntuiText __far __aligned IText1 = {
  667.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  668.     0,0,    /* XY origin relative to container TopLeft */
  669.     &TOPAZ80,    /* font pointer or NULL for default */
  670.     "Set Time",    /* pointer to text */
  671.     NULL    /* next IntuiText structure */
  672. };
  673.  
  674. struct MenuItem __aligned MenuItem3 = {
  675.     &MenuItem3r,    /* next MenuItem structure */
  676.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  677.     72,8,    /* hit box width and height */
  678.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  679.     0,    /* each bit mutually-excludes a same-level Item */
  680.     (APTR)&IText1,    /* Item render  (IntuiText or Image or NULL) */
  681.     NULL,    /* Select render */
  682.     NULL,    /* alternate command-key */
  683.     NULL,    /* SubItem list */
  684.     MENUNULL    /* filled in by Intuition for drag selections */
  685. };
  686.  
  687. struct IntuiText __far __aligned IText2x = {
  688.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  689.     0,0,    /* XY origin relative to container TopLeft */
  690.     &TOPAZ80,    /* font pointer or NULL for default */
  691.     "Rate Pgm",    /* pointer to text */
  692.     NULL    /* next IntuiText structure */
  693. };
  694.  
  695. struct MenuItem __aligned MenuItem3x = {
  696.     &MenuItem3,    /* next MenuItem structure */
  697.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  698.     72,8,    /* hit box width and height */
  699.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  700.     0,    /* each bit mutually-excludes a same-level Item */
  701.     (APTR)&IText2x,    /* Item render  (IntuiText or Image or NULL) */
  702.     NULL,    /* Select render */
  703.     NULL,    /* alternate command-key */
  704.     NULL,    /* SubItem list */
  705.     MENUNULL    /* filled in by Intuition for drag selections */
  706. };
  707.  
  708. struct IntuiText __far __aligned IText2 = {
  709.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  710.     0,0,    /* XY origin relative to container TopLeft */
  711.     &TOPAZ80,    /* font pointer or NULL for default */
  712.     "Test",    /* pointer to text */
  713.     NULL    /* next IntuiText structure */
  714. };
  715.  
  716. struct MenuItem __aligned MenuItem2 = {
  717.     &MenuItem3x,    /* next MenuItem structure */
  718.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  719.     72,8,    /* hit box width and height */
  720.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  721.     0,    /* each bit mutually-excludes a same-level Item */
  722.     (APTR)&IText2,    /* Item render  (IntuiText or Image or NULL) */
  723.     NULL,    /* Select render */
  724.     NULL,    /* alternate command-key */
  725.     NULL,    /* SubItem list */
  726.     MENUNULL    /* filled in by Intuition for drag selections */
  727. };
  728.  
  729. struct IntuiText __far __aligned IText3 = {
  730.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  731.     0,0,    /* XY origin relative to container TopLeft */
  732.     &TOPAZ80,    /* font pointer or NULL for default */
  733.     "Hint",    /* pointer to text */
  734.     NULL    /* next IntuiText structure */
  735. };
  736.  
  737. struct MenuItem __aligned MenuItem1 = {
  738.     &MenuItem2,    /* next MenuItem structure */
  739.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  740.     72,8,    /* hit box width and height */
  741.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  742.     0,    /* each bit mutually-excludes a same-level Item */
  743.     (APTR)&IText3,    /* Item render  (IntuiText or Image or NULL) */
  744.     NULL,    /* Select render */
  745.     'H',    /* alternate command-key */
  746.     NULL,    /* SubItem list */
  747.     MENUNULL    /* filled in by Intuition for drag selections */
  748. };
  749.  
  750. struct Menu __aligned Menu4 = {
  751.     NULL,    /* next Menu structure */
  752.     162,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  753.     63,0,    /* Menu hit box width and height */
  754.     MENUENABLED,    /* Menu flags */
  755.     "Special",    /* text of Menu name */
  756.     &MenuItem1    /* MenuItem linked list pointer */
  757. };
  758.  
  759. struct IntuiText __far __aligned IText4cc = {
  760.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  761.     19,0,    /* XY origin relative to container TopLeft */
  762.     &TOPAZ80,    /* font pointer or NULL for default */
  763.     "Easy",    /* pointer to text */
  764.     NULL    /* next IntuiText structure */
  765. };
  766.  
  767. struct MenuItem __aligned MenuItem8cc = {
  768.     NULL,    /* next MenuItem structure */
  769.     0,80,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  770.     123,8,    /* hit box width and height */
  771.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  772.     EXCLUDE_PATT^(0x400),    /* each bit mutually-excludes a same-level Item */
  773.     (APTR)&IText4cc,    /* Item render  (IntuiText or Image or NULL) */
  774.     NULL,    /* Select render */
  775.     'E',    /* alternate command-key */
  776.     NULL,    /* SubItem list */
  777.     MENUNULL    /* filled in by Intuition for drag selections */
  778. };
  779.  
  780. struct IntuiText __far __aligned IText4dd = {
  781.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  782.     19,0,    /* XY origin relative to container TopLeft */
  783.     &TOPAZ80,    /* font pointer or NULL for default */
  784.     "Intrmdt",    /* pointer to text */
  785.     NULL    /* next IntuiText structure */
  786. };
  787.  
  788. struct MenuItem __aligned MenuItem8dd = {
  789.     &MenuItem8cc,    /* next MenuItem structure */
  790.     0,72,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  791.     123,8,    /* hit box width and height */
  792.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  793.     EXCLUDE_PATT^(0x200),    /* each bit mutually-excludes a same-level Item */
  794.     (APTR)&IText4dd,    /* Item render  (IntuiText or Image or NULL) */
  795.     NULL,    /* Select render */
  796.     'I',    /* alternate command-key */
  797.     NULL,    /* SubItem list */
  798.     MENUNULL    /* filled in by Intuition for drag selections */
  799. };
  800.  
  801. struct IntuiText __far __aligned IText4ee = {
  802.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  803.     19,0,    /* XY origin relative to container TopLeft */
  804.     &TOPAZ80,    /* font pointer or NULL for default */
  805.     "Advancd",    /* pointer to text */
  806.     NULL    /* next IntuiText structure */
  807. };
  808.  
  809. struct MenuItem __aligned MenuItem8ee = {
  810.     &MenuItem8dd,    /* next MenuItem structure */
  811.     0,64,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  812.     123,8,    /* hit box width and height */
  813.     CHECKED+CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+HIGHCOMP,    /* Item flags */
  814.     EXCLUDE_PATT^(0x100),    /* each bit mutually-excludes a same-level Item */
  815.     (APTR)&IText4ee,    /* Item render  (IntuiText or Image or NULL) */
  816.     NULL,    /* Select render */
  817.     'A',    /* alternate command-key */
  818.     NULL,    /* SubItem list */
  819.     MENUNULL    /* filled in by Intuition for drag selections */
  820. };
  821.  
  822. struct IntuiText __far __aligned IText4aa = {
  823.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  824.     19,0,    /* XY origin relative to container TopLeft */
  825.     &TOPAZ80,    /* font pointer or NULL for default */
  826.     "Supvsr",    /* pointer to text */
  827.     NULL    /* next IntuiText structure */
  828. };
  829.  
  830. struct MenuItem __aligned MenuItem8aa = {
  831.     &MenuItem8ee,    /* next MenuItem structure */
  832.     0,56,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  833.     123,8,    /* hit box width and height */
  834.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  835.     0,    /* each bit mutually-excludes a same-level Item */
  836.     (APTR)&IText4aa,    /* Item render  (IntuiText or Image or NULL) */
  837.     NULL,    /* Select render */
  838.     'Y',    /* alternate command-key */
  839.     NULL,    /* SubItem list */
  840.     MENUNULL    /* filled in by Intuition for drag selections */
  841. };
  842.  
  843. struct IntuiText __far __aligned IText4ab = {
  844.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  845.     19,0,    /* XY origin relative to container TopLeft */
  846.     &TOPAZ80,    /* font pointer or NULL for default */
  847.     "Book",    /* pointer to text */
  848.     NULL    /* next IntuiText structure */
  849. };
  850.  
  851. struct MenuItem __aligned MenuItem8ab = {
  852.       &MenuItem8aa,    /* next MenuItem structure */
  853.     0,48,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  854.     123,8,    /* hit box width and height */
  855.     CHECKIT+CHECKED+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  856.     0,    /* each bit mutually-excludes a same-level Item */
  857.     (APTR)&IText4ab,    /* Item render  (IntuiText or Image or NULL) */
  858.     NULL,    /* Select render */
  859.     'B',    /* alternate command-key */
  860.     NULL,    /* SubItem list */
  861.     MENUNULL    /* filled in by Intuition for drag selections */
  862. };
  863.  
  864. struct IntuiText __far __aligned IText4a = {
  865.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  866.     19,0,    /* XY origin relative to container TopLeft */
  867.     &TOPAZ80,    /* font pointer or NULL for default */
  868.     "ShwThnk",    /* pointer to text */
  869.     NULL    /* next IntuiText structure */
  870. };
  871.  
  872. struct MenuItem __aligned MenuItem8a = {
  873.     &MenuItem8ab,    /* next MenuItem structure */
  874.     0,40,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  875.     123,8,    /* hit box width and height */
  876.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  877.     0,    /* each bit mutually-excludes a same-level Item */
  878.     (APTR)&IText4a,    /* Item render  (IntuiText or Image or NULL) */
  879.     NULL,    /* Select render */
  880.     'V',    /* alternate command-key */
  881.     NULL,    /* SubItem list */
  882.     MENUNULL    /* filled in by Intuition for drag selections */
  883. };
  884.  
  885. struct IntuiText __far __aligned IText4 = {
  886.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  887.     19,0,    /* XY origin relative to container TopLeft */
  888.     &TOPAZ80,    /* font pointer or NULL for default */
  889.     "Thinking",    /* pointer to text */
  890.     NULL    /* next IntuiText structure */
  891. };
  892.  
  893. struct MenuItem __aligned MenuItem8 = {
  894.     &MenuItem8a,    /* next MenuItem structure */
  895.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  896.     123,8,    /* hit box width and height */
  897.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ/*+ITEMENABLED*/+HIGHCOMP,    /* Item flags */
  898.     0,    /* each bit mutually-excludes a same-level Item */
  899.     (APTR)&IText4,    /* Item render  (IntuiText or Image or NULL) */
  900.     NULL,    /* Select render */
  901.     'T',    /* alternate command-key */
  902.     NULL,    /* SubItem list */
  903.     MENUNULL    /* filled in by Intuition for drag selections */
  904. };
  905.  
  906. struct IntuiText __far __aligned IText5 = {
  907.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  908.     0,0,    /* XY origin relative to container TopLeft */
  909.     &TOPAZ80,    /* font pointer or NULL for default */
  910.     "Undo",    /* pointer to text */
  911.     NULL    /* next IntuiText structure */
  912. };
  913.  
  914. struct MenuItem __aligned MenuItem7 = {
  915.     &MenuItem8,    /* next MenuItem structure */
  916.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  917.     123,8,    /* hit box width and height */
  918.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  919.     0,    /* each bit mutually-excludes a same-level Item */
  920.     (APTR)&IText5,    /* Item render  (IntuiText or Image or NULL) */
  921.     NULL,    /* Select render */
  922.     'U',    /* alternate command-key */
  923.     NULL,    /* SubItem list */
  924.     MENUNULL    /* filled in by Intuition for drag selections */
  925. };
  926.  
  927. struct IntuiText __far __aligned IText6 = {
  928.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  929.     0,0,    /* XY origin relative to container TopLeft */
  930.     &TOPAZ80,    /* font pointer or NULL for default */
  931.     "Move Now",    /* pointer to text */
  932.     NULL    /* next IntuiText structure */
  933. };
  934.  
  935. struct MenuItem __aligned MenuItem6 = {
  936.     &MenuItem7,    /* next MenuItem structure */
  937.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  938.     123,8,    /* hit box width and height */
  939.     ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  940.     0,    /* each bit mutually-excludes a same-level Item */
  941.     (APTR)&IText6,    /* Item render  (IntuiText or Image or NULL) */
  942.     NULL,    /* Select render */
  943.     'M',    /* alternate command-key */
  944.     NULL,    /* SubItem list */
  945.     MENUNULL    /* filled in by Intuition for drag selections */
  946. };
  947.  
  948. struct IntuiText __far __aligned IText7 = {
  949.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  950.     0,0,    /* XY origin relative to container TopLeft */
  951.     &TOPAZ80,    /* font pointer or NULL for default */
  952.     "AutoPlay",    /* pointer to text */
  953.     NULL    /* next IntuiText structure */
  954. };
  955.  
  956. struct MenuItem __aligned MenuItem5 = {
  957.     &MenuItem6,    /* next MenuItem structure */
  958.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  959.     123,8,    /* hit box width and height */
  960.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  961.     0,    /* each bit mutually-excludes a same-level Item */
  962.     (APTR)&IText7,    /* Item render  (IntuiText or Image or NULL) */
  963.     NULL,    /* Select render */
  964.     NULL,    /* alternate command-key */
  965.     NULL,    /* SubItem list */
  966.     MENUNULL    /* filled in by Intuition for drag selections */
  967. };
  968.  
  969. struct IntuiText __far __aligned IText8 = {
  970.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  971.     0,0,    /* XY origin relative to container TopLeft */
  972.     &TOPAZ80,    /* font pointer or NULL for default */
  973.     "Swap Sides",    /* pointer to text */
  974.     NULL    /* next IntuiText structure */
  975. };
  976.  
  977. struct MenuItem __aligned MenuItem4 = {
  978.     &MenuItem5,    /* next MenuItem structure */
  979.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  980.     123,8,    /* hit box width and height */
  981.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  982.     0,    /* each bit mutually-excludes a same-level Item */
  983.     (APTR)&IText8,    /* Item render  (IntuiText or Image or NULL) */
  984.     NULL,    /* Select render */
  985.     'S',    /* alternate command-key */
  986.     NULL,    /* SubItem list */
  987.     MENUNULL    /* filled in by Intuition for drag selections */
  988. };
  989.  
  990. struct Menu __aligned Menu3 = {
  991.     &Menu4,    /* next Menu structure */
  992.     92,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  993.     63,0,    /* Menu hit box width and height */
  994.     MENUENABLED,    /* Menu flags */
  995.     "Control",    /* text of Menu name */
  996.     &MenuItem4    /* MenuItem linked list pointer */
  997. };
  998.  
  999. struct IntuiText __far __aligned IText9 = {
  1000.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1001.     0,0,    /* XY origin relative to container TopLeft */
  1002.     &TOPAZ80,    /* font pointer or NULL for default */
  1003.     "ReverseBoard",    /* pointer to text */
  1004.     NULL    /* next IntuiText structure */
  1005. };
  1006.  
  1007. struct MenuItem __aligned MenuItem11 = {
  1008.     NULL,    /* next MenuItem structure */
  1009.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1010.     96,8,    /* hit box width and height */
  1011.     ITEMTEXT+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  1012.     0,    /* each bit mutually-excludes a same-level Item */
  1013.     (APTR)&IText9,    /* Item render  (IntuiText or Image or NULL) */
  1014.     NULL,    /* Select render */
  1015.     NULL,    /* alternate command-key */
  1016.     NULL,    /* SubItem list */
  1017.     MENUNULL    /* filled in by Intuition for drag selections */
  1018. };
  1019.  
  1020. struct IntuiText __far __aligned IText10 = {
  1021.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1022.     19,0,    /* XY origin relative to container TopLeft */
  1023.     &TOPAZ80,    /* font pointer or NULL for default */
  1024.     "Edit Board",    /* pointer to text */
  1025.     NULL    /* next IntuiText structure */
  1026. };
  1027.  
  1028. struct MenuItem __aligned MenuItem10 = {
  1029.     &MenuItem11,    /* next MenuItem structure */
  1030.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1031.     96,8,    /* hit box width and height */
  1032.     ITEMTEXT+HIGHCOMP+ITEMENABLED,    /* Item flags */
  1033.     0,    /* each bit mutually-excludes a same-level Item */
  1034.     (APTR)&IText10,    /* Item render  (IntuiText or Image or NULL) */
  1035.     NULL,    /* Select render */
  1036.     NULL,    /* alternate command-key */
  1037.     NULL,    /* SubItem list */
  1038.     MENUNULL    /* filled in by Intuition for drag selections */
  1039. };
  1040.  
  1041. struct IntuiText __far __aligned IText11 = {
  1042.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1043.     19,0,    /* XY origin relative to container TopLeft */
  1044.     &TOPAZ80,    /* font pointer or NULL for default */
  1045.     "2-D",    /* pointer to text */
  1046.     NULL    /* next IntuiText structure */
  1047. };
  1048.  
  1049. struct MenuItem __aligned MenuItem9 = {
  1050.     &MenuItem10,    /* next MenuItem structure */
  1051.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1052.     96,8,    /* hit box width and height */
  1053.     CHECKED+CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1054.     0,    /* each bit mutually-excludes a same-level Item */
  1055.     (APTR)&IText11,    /* Item render  (IntuiText or Image or NULL) */
  1056.     NULL,    /* Select render */
  1057.     NULL,    /* alternate command-key */
  1058.     NULL,    /* SubItem list */
  1059.     MENUNULL    /* filled in by Intuition for drag selections */
  1060. };
  1061.  
  1062. struct Menu __aligned Menu2 = {
  1063.     &Menu3,    /* next Menu structure */
  1064.     46,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  1065.     39,0,    /* Menu hit box width and height */
  1066.     MENUENABLED,    /* Menu flags */
  1067.     "View",    /* text of Menu name */
  1068.     &MenuItem9    /* MenuItem linked list pointer */
  1069. };
  1070.  
  1071. struct IntuiText __far __aligned IText12 = {
  1072.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1073.     0,0,    /* XY origin relative to container TopLeft */
  1074.     &TOPAZ80,    /* font pointer or NULL for default */
  1075.     "Quit",    /* pointer to text */
  1076.     NULL    /* next IntuiText structure */
  1077. };
  1078.  
  1079. struct MenuItem __aligned MenuItem15 = {
  1080.     NULL,    /* next MenuItem structure */
  1081.     0,40,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1082.     72,8,    /* hit box width and height */
  1083.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1084.     0,    /* each bit mutually-excludes a same-level Item */
  1085.     (APTR)&IText12,    /* Item render  (IntuiText or Image or NULL) */
  1086.     NULL,    /* Select render */
  1087.     'Q',    /* alternate command-key */
  1088.     NULL,    /* SubItem list */
  1089.     MENUNULL    /* filled in by Intuition for drag selections */
  1090. };
  1091.  
  1092. struct IntuiText __far __aligned IText13a = {
  1093.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1094.     0,0,    /* XY origin relative to container TopLeft */
  1095.     &TOPAZ80,    /* font pointer or NULL for default */
  1096.     "List Game",    /* pointer to text */
  1097.     NULL    /* next IntuiText structure */
  1098. };
  1099.  
  1100. struct MenuItem __aligned MenuItem14a = {
  1101.     &MenuItem15,    /* next MenuItem structure */
  1102.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1103.     72,8,    /* hit box width and height */
  1104.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1105.     0,    /* each bit mutually-excludes a same-level Item */
  1106.     (APTR)&IText13a,/* Item render  (IntuiText or Image or NULL) */
  1107.     NULL,    /* Select render */
  1108.     NULL,    /* alternate command-key */
  1109.     NULL,    /* SubItem list */
  1110.     MENUNULL    /* filled in by Intuition for drag selections */
  1111. };
  1112.  
  1113. struct IntuiText __far __aligned IText13 = {
  1114.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1115.     0,0,    /* XY origin relative to container TopLeft */
  1116.     &TOPAZ80,    /* font pointer or NULL for default */
  1117.     "Save Game",    /* pointer to text */
  1118.     NULL    /* next IntuiText structure */
  1119. };
  1120.  
  1121. struct MenuItem __aligned MenuItem14 = {
  1122.     &MenuItem14a,    /* next MenuItem structure */
  1123.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1124.     72,8,    /* hit box width and height */
  1125.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1126.     0,    /* each bit mutually-excludes a same-level Item */
  1127.     (APTR)&IText13,    /* Item render  (IntuiText or Image or NULL) */
  1128.     NULL,    /* Select render */
  1129.     NULL,    /* alternate command-key */
  1130.     NULL,    /* SubItem list */
  1131.     MENUNULL    /* filled in by Intuition for drag selections */
  1132. };
  1133.  
  1134. struct IntuiText __far __aligned IText14 = {
  1135.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1136.     0,0,    /* XY origin relative to container TopLeft */
  1137.     &TOPAZ80,    /* font pointer or NULL for default */
  1138.     "Load Game",    /* pointer to text */
  1139.     NULL    /* next IntuiText structure */
  1140. };
  1141.  
  1142. struct MenuItem __aligned MenuItem13 = {
  1143.     &MenuItem14,    /* next MenuItem structure */
  1144.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1145.     72,8,    /* hit box width and height */
  1146.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1147.     0,    /* each bit mutually-excludes a same-level Item */
  1148.     (APTR)&IText14,    /* Item render  (IntuiText or Image or NULL) */
  1149.     NULL,    /* Select render */
  1150.     NULL,    /* alternate command-key */
  1151.     NULL,    /* SubItem list */
  1152.     MENUNULL    /* filled in by Intuition for drag selections */
  1153. };
  1154.  
  1155. struct MenuItem __aligned MenuItem28 = {
  1156.     &MenuItem13,    /* next MenuItem structure */
  1157.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1158.     72,8,    /* hit box width and height */
  1159.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1160.     0,    /* each bit mutually-excludes a same-level Item */
  1161.     (APTR)&IText37,    /* Item render  (IntuiText or Image or NULL) */
  1162.     NULL,    /* Select render */
  1163.     NULL,    /* alternate command-key */
  1164.     NULL,    /* SubItem list */
  1165.     MENUNULL    /* filled in by Intuition for drag selections */
  1166. };
  1167.  
  1168. struct IntuiText __far __aligned IText15 = {
  1169.     TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1170.     0,0,    /* XY origin relative to container TopLeft */
  1171.     &TOPAZ80,    /* font pointer or NULL for default */
  1172.     "About..",    /* pointer to text */
  1173.     NULL    /* next IntuiText structure */
  1174. };
  1175.  
  1176. struct MenuItem __aligned MenuItem12 = {
  1177.     &MenuItem28,    /* next MenuItem structure */
  1178.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1179.     72,8,    /* hit box width and height */
  1180.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1181.     0,    /* each bit mutually-excludes a same-level Item */
  1182.     (APTR)&IText15,    /* Item render  (IntuiText or Image or NULL) */
  1183.     NULL,    /* Select render */
  1184.     NULL,    /* alternate command-key */
  1185.     NULL,    /* SubItem list */
  1186.     MENUNULL    /* filled in by Intuition for drag selections */
  1187. };
  1188.  
  1189. struct Menu __aligned Menu1 = {
  1190.     &Menu2,    /* next Menu structure */
  1191.     0,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  1192.     39,0,    /* Menu hit box width and height */
  1193.     MENUENABLED,    /* Menu flags */
  1194.     "File",    /* text of Menu name */
  1195.     &MenuItem12    /* MenuItem linked list pointer */
  1196. };
  1197.  
  1198. #define MenuList1 Menu1
  1199.  
  1200. struct NewWindow __aligned NewWindowStructure1 = {
  1201.     0,0,    /* window XY origin relative to TopLeft of screen */
  1202.     WIDTH,THEIGHT,    /* window width and height */
  1203.     0,TBLOCKPEN,    /* detail and block pens */
  1204.     MOUSEBUTTONS|MENUPICK|RAWKEY,    /* IDCMP flags */
  1205.     BACKDROP+BORDERLESS+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1206.     NULL,    /* first gadget in gadget list */
  1207.     NULL,    /* custom CHECKMARK imagery */
  1208.     " ",    /* window title */
  1209.     NULL,    /* custom screen pointer */
  1210.     NULL,    /* custom bitmap */
  1211.     WIDTH,THEIGHT,    /* minimum width and height */
  1212.     0xffff,0xffff,    /* maximum width and height */
  1213.     CUSTOMSCREEN    /* destination screen type */
  1214. };
  1215.  
  1216. SHORT __far __aligned BorderVectors1[] = {
  1217.     0,0,
  1218.     81,0,
  1219.     81,38,
  1220.     0,38,
  1221.     0,0
  1222. };
  1223. struct Border __far __aligned Border1 = {
  1224.     -1,-1,    /* XY origin relative to container TopLeft */
  1225.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1226.     5,    /* number of XY vectors */
  1227.     BorderVectors1,    /* pointer to XY vectors */
  1228.     NULL    /* next border in list */
  1229. };
  1230.  
  1231. struct IntuiText __far __aligned IText16 = {
  1232.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1233.     31,15,    /* XY origin relative to container TopLeft */
  1234.     NULL,    /* font pointer or NULL for default */
  1235.     "OK",    /* pointer to text */
  1236.     NULL    /* next IntuiText structure */
  1237. };
  1238.  
  1239. struct Gadget __far __aligned Gadget1 = {
  1240.     NULL,    /* next gadget */
  1241.     155,233,    /* origin XY of hit box relative to window TopLeft */
  1242.     80,37,    /* hit box width and height */
  1243.     NULL,    /* gadget flags */
  1244.     RELVERIFY,    /* activation flags */
  1245.     BOOLGADGET,    /* gadget type flags */
  1246.     (APTR)&Border1,    /* gadget border or image to be rendered */
  1247.     NULL,    /* alternate imagery for selection */
  1248.     &IText16,    /* first IntuiText structure */
  1249.     NULL,    /* gadget mutual-exclude long word */
  1250.     NULL,    /* SpecialInfo structure */
  1251.     NULL,    /* user-definable data */
  1252.     NULL    /* pointer to user-definable data */
  1253. };
  1254.  
  1255. #define GadgetList2 Gadget1
  1256.  
  1257. struct IntuiText __far __aligned IText22 = {
  1258.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1259.     143,130,    /* XY origin relative to container TopLeft */
  1260.     NULL,    /* font pointer or NULL for default */
  1261.     "of Computers.",    /* pointer to text */
  1262.     NULL    /* next IntuiText structure */
  1263. };
  1264.  
  1265. struct IntuiText __far __aligned IText21 = {
  1266.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1267.     115,117,    /* XY origin relative to container TopLeft */
  1268.     NULL,    /* font pointer or NULL for default */
  1269.     "For the Amiga Family",    /* pointer to text */
  1270.     &IText22    /* next IntuiText structure */
  1271. };
  1272.  
  1273. struct IntuiText __far __aligned IText20 = {
  1274.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1275.     104,102,    /* XY origin relative to container TopLeft */
  1276.     NULL,    /* font pointer or NULL for default */
  1277.     "Chess Program Available",    /* pointer to text */
  1278.     &IText21    /* next IntuiText structure */
  1279. };
  1280.  
  1281. struct IntuiText __far __aligned IText19 = {
  1282.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1283.     108,87,    /* XY origin relative to container TopLeft */
  1284.     NULL,    /* font pointer or NULL for default */
  1285.     "The strongest Playing",    /* pointer to text */
  1286.     &IText20    /* next IntuiText structure */
  1287. };
  1288.  
  1289. struct IntuiText __far __aligned IText18 = {
  1290.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1291.     126,31,    /* XY origin relative to container TopLeft */
  1292.     NULL,    /* font pointer or NULL for default */
  1293.     "by Roger Uzun",    /* pointer to text */
  1294.     &IText19    /* next IntuiText structure */
  1295. };
  1296.  
  1297. struct IntuiText __far __aligned IText17 = {
  1298.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1299.     131,18,    /* XY origin relative to container TopLeft */
  1300.     NULL,    /* font pointer or NULL for default */
  1301.     VERSTRING,    /* pointer to text */
  1302.     &IText18    /* next IntuiText structure */
  1303. };
  1304.  
  1305. struct NewWindow __far __aligned NewWindowStructure2 = {
  1306.     125,30,    /* window XY origin relative to TopLeft of screen */
  1307.     390,290,    /* window width and height */
  1308.     0,TBLOCKPEN,    /* detail and block pens */
  1309.     VANILLAKEY|GADGETUP,    /* IDCMP flags */
  1310.     SIMPLE_REFRESH+NOCAREREFRESH+ACTIVATE,    /* other window flags */
  1311.     &Gadget1,    /* first gadget in gadget list */
  1312.     NULL,    /* custom CHECKMARK imagery */
  1313. #ifdef _M68040
  1314.     "UChess Pro",    /* window title */
  1315. #else
  1316.     "UChess Jr.",    /* window title */
  1317. #endif
  1318.     NULL,    /* custom screen pointer */
  1319.     NULL,    /* custom bitmap */
  1320.     5,5,    /* minimum width and height */
  1321.     0xffff,0xffff,    /* maximum width and height */
  1322.     CUSTOMSCREEN    /* destination screen type */
  1323. };
  1324.  
  1325.  
  1326. SHORT __far __aligned aBorderVectors1[] = {
  1327.     0,0,
  1328.     77,0,
  1329.     77,25,
  1330.     0,25,
  1331.     0,0
  1332. };
  1333. struct Border __far __aligned aBorder1 = {
  1334.     -1,-1,    /* XY origin relative to container TopLeft */
  1335.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1336.     5,    /* number of XY vectors */
  1337.     aBorderVectors1,    /* pointer to XY vectors */
  1338.     NULL    /* next border in list */
  1339. };
  1340.  
  1341. struct IntuiText __far __aligned aIText1 = {
  1342.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1343.     16,8,    /* XY origin relative to container TopLeft */
  1344.     NULL,    /* font pointer or NULL for default */
  1345.     "KNIGHT",    /* pointer to text */
  1346.     NULL    /* next IntuiText structure */
  1347. };
  1348.  
  1349. struct Gadget __far __aligned aGadget4 = {
  1350.     NULL,    /* next gadget */
  1351.     55,124,    /* origin XY of hit box relative to window TopLeft */
  1352.     76,24,    /* hit box width and height */
  1353.     NULL,    /* gadget flags */
  1354.     RELVERIFY,    /* activation flags */
  1355.     BOOLGADGET,    /* gadget type flags */
  1356.     (APTR)&aBorder1,    /* gadget border or image to be rendered */
  1357.     NULL,    /* alternate imagery for selection */
  1358.     &aIText1,    /* first IntuiText structure */
  1359.     NULL,    /* gadget mutual-exclude long word */
  1360.     NULL,    /* SpecialInfo structure */
  1361.     NULL,    /* user-definable data */
  1362.     NULL    /* pointer to user-definable data */
  1363. };
  1364.  
  1365. SHORT __far __aligned aBorderVectors2[] = {
  1366.     0,0,
  1367.     77,0,
  1368.     77,25,
  1369.     0,25,
  1370.     0,0
  1371. };
  1372. struct Border __far __aligned aBorder2 = {
  1373.     -1,-1,    /* XY origin relative to container TopLeft */
  1374.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1375.     5,    /* number of XY vectors */
  1376.     aBorderVectors2,    /* pointer to XY vectors */
  1377.     NULL    /* next border in list */
  1378. };
  1379.  
  1380. struct IntuiText __far __aligned aIText2 = {
  1381.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1382.     15,8,    /* XY origin relative to container TopLeft */
  1383.     NULL,    /* font pointer or NULL for default */
  1384.     "BISHOP",    /* pointer to text */
  1385.     NULL    /* next IntuiText structure */
  1386. };
  1387.  
  1388. struct Gadget __far __aligned aGadget3 = {
  1389.     &aGadget4,    /* next gadget */
  1390.     55,92,    /* origin XY of hit box relative to window TopLeft */
  1391.     76,24,    /* hit box width and height */
  1392.     NULL,    /* gadget flags */
  1393.     RELVERIFY,    /* activation flags */
  1394.     BOOLGADGET,    /* gadget type flags */
  1395.     (APTR)&aBorder2,    /* gadget border or image to be rendered */
  1396.     NULL,    /* alternate imagery for selection */
  1397.     &aIText2,    /* first IntuiText structure */
  1398.     NULL,    /* gadget mutual-exclude long word */
  1399.     NULL,    /* SpecialInfo structure */
  1400.     NULL,    /* user-definable data */
  1401.     NULL    /* pointer to user-definable data */
  1402. };
  1403.  
  1404. SHORT __far __aligned aBorderVectors3[] = {
  1405.     0,0,
  1406.     77,0,
  1407.     77,25,
  1408.     0,25,
  1409.     0,0
  1410. };
  1411. struct Border __far __aligned aBorder3 = {
  1412.     -1,-1,    /* XY origin relative to container TopLeft */
  1413.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1414.     5,    /* number of XY vectors */
  1415.     aBorderVectors3,    /* pointer to XY vectors */
  1416.     NULL    /* next border in list */
  1417. };
  1418.  
  1419. struct IntuiText __far __aligned aIText3 = {
  1420.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1421.     19,8,    /* XY origin relative to container TopLeft */
  1422.     NULL,    /* font pointer or NULL for default */
  1423.     "ROOK",    /* pointer to text */
  1424.     NULL    /* next IntuiText structure */
  1425. };
  1426.  
  1427. struct Gadget __far __aligned aGadget2 = {
  1428.     &aGadget3,    /* next gadget */
  1429.     55,60,    /* origin XY of hit box relative to window TopLeft */
  1430.     76,24,    /* hit box width and height */
  1431.     NULL,    /* gadget flags */
  1432.     RELVERIFY,    /* activation flags */
  1433.     BOOLGADGET,    /* gadget type flags */
  1434.     (APTR)&aBorder3,    /* gadget border or image to be rendered */
  1435.     NULL,    /* alternate imagery for selection */
  1436.     &aIText3,    /* first IntuiText structure */
  1437.     NULL,    /* gadget mutual-exclude long word */
  1438.     NULL,    /* SpecialInfo structure */
  1439.     NULL,    /* user-definable data */
  1440.     NULL    /* pointer to user-definable data */
  1441. };
  1442.  
  1443. SHORT __far __aligned aBorderVectors4[] = {
  1444.     0,0,
  1445.     77,0,
  1446.     77,25,
  1447.     0,25,
  1448.     0,0
  1449. };
  1450. struct Border __far __aligned aBorder4 = {
  1451.     -1,-1,    /* XY origin relative to container TopLeft */
  1452.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1453.     5,    /* number of XY vectors */
  1454.     aBorderVectors4,    /* pointer to XY vectors */
  1455.     NULL    /* next border in list */
  1456. };
  1457.  
  1458. struct IntuiText __far __aligned aIText4 = {
  1459.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1460.     16,8,    /* XY origin relative to container TopLeft */
  1461.     NULL,    /* font pointer or NULL for default */
  1462.     "QUEEN",    /* pointer to text */
  1463.     NULL    /* next IntuiText structure */
  1464. };
  1465.  
  1466. struct Gadget __far __aligned aGadget1 = {
  1467.     &aGadget2,    /* next gadget */
  1468.     55,28,    /* origin XY of hit box relative to window TopLeft */
  1469.     76,24,    /* hit box width and height */
  1470.     NULL,    /* gadget flags */
  1471.     RELVERIFY,    /* activation flags */
  1472.     BOOLGADGET,    /* gadget type flags */
  1473.     (APTR)&aBorder4,    /* gadget border or image to be rendered */
  1474.     NULL,    /* alternate imagery for selection */
  1475.     &aIText4,    /* first IntuiText structure */
  1476.     NULL,    /* gadget mutual-exclude long word */
  1477.     NULL,    /* SpecialInfo structure */
  1478.     NULL,    /* user-definable data */
  1479.     NULL    /* pointer to user-definable data */
  1480. };
  1481.  
  1482.  
  1483. struct IntuiText __far __aligned aIText5 = {
  1484.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1485.     33,14,    /* XY origin relative to container TopLeft */
  1486.     &TOPAZ80,    /* font pointer or NULL for default */
  1487.     "Promote Pawn to",    /* pointer to text */
  1488.     NULL    /* next IntuiText structure */
  1489. };
  1490.  
  1491.  
  1492. struct NewWindow __aligned NewWindowStructure6 = {
  1493.     220,35,    /* window XY origin relative to TopLeft of screen */
  1494.     200,170,    /* window width and height */
  1495.     0,TBLOCKPEN,    /* detail and block pens */
  1496.     GADGETUP,    /* IDCMP flags */
  1497.     SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1498.     &aGadget1,    /* first gadget in gadget list */
  1499.     NULL,    /* custom CHECKMARK imagery */
  1500.     "Promote Piece",    /* window title */
  1501.     NULL,    /* custom screen pointer */
  1502.     NULL,    /* custom bitmap */
  1503.     5,5,    /* minimum width and height */
  1504.     0xffff,0xffff,    /* maximum width and height */
  1505.     CUSTOMSCREEN    /* destination screen type */
  1506. };
  1507.  
  1508. #define MOVENOWMENUNUM 0x42
  1509. #define THINKMENUNUM 0x82
  1510. #define SHOWMENUNUM 0xa2
  1511. #define BOOKMENUNUM 0xc2
  1512. #define SUPERMENUNUM 0xe2
  1513. #define ADVANCEDMENUNUM 0x102
  1514. #define INTERMEDIATEMENUNUM 0x122
  1515. #define EASYMENUNUM 0x142
  1516.  
  1517.  
  1518. SHORT __far __aligned pBorderVectors1[] = {
  1519.     0,0,
  1520.     68,0,
  1521.     68,31,
  1522.     0,31,
  1523.     0,0
  1524. };
  1525. struct Border __far __aligned pBorder1 = {
  1526.     -1,-1,    /* XY origin relative to container TopLeft */
  1527.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1528.     5,    /* number of XY vectors */
  1529.     pBorderVectors1,    /* pointer to XY vectors */
  1530.     NULL    /* next border in list */
  1531. };
  1532.  
  1533. struct IntuiText __far __aligned pIText1 = {
  1534.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1535.     13,11,    /* XY origin relative to container TopLeft */
  1536.     &TOPAZ80,    /* font pointer or NULL for default */
  1537.     "DONE",    /* pointer to text */
  1538.     NULL    /* next IntuiText structure */
  1539. };
  1540.  
  1541. struct Gadget __far __aligned pGadget4 = {
  1542.     NULL,    /* next gadget */
  1543.     104,172,    /* origin XY of hit box relative to window TopLeft */
  1544.     67,30,    /* hit box width and height */
  1545.     NULL,    /* gadget flags */
  1546.     RELVERIFY,    /* activation flags */
  1547.     BOOLGADGET,    /* gadget type flags */
  1548.     (APTR)&pBorder1,    /* gadget border or image to be rendered */
  1549.     NULL,    /* alternate imagery for selection */
  1550.     &pIText1,    /* first IntuiText structure */
  1551.     NULL,    /* gadget mutual-exclude long word */
  1552.     NULL,    /* SpecialInfo structure */
  1553.     NULL,    /* user-definable data */
  1554.     NULL    /* pointer to user-definable data */
  1555. };
  1556.  
  1557. SHORT __far __aligned pBorderVectors2[] = {
  1558.     0,0,
  1559.     68,0,
  1560.     68,31,
  1561.     0,31,
  1562.     0,0
  1563. };
  1564. struct Border __far __aligned pBorder2 = {
  1565.     -1,-1,    /* XY origin relative to container TopLeft */
  1566.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1567.     5,    /* number of XY vectors */
  1568.     pBorderVectors2,    /* pointer to XY vectors */
  1569.     NULL    /* next border in list */
  1570. };
  1571.  
  1572. struct IntuiText __far __aligned pIText2 = {
  1573.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1574.     117,132,    /* was 13,11 XY origin relative to container TopLeft */
  1575.     &TOPAZ80,    /* font pointer or NULL for default */
  1576.     "WHITE",    /* pointer to text */
  1577.     NULL    /* next IntuiText structure */
  1578. };
  1579.  
  1580. struct IntuiText __far __aligned pIText2a = {
  1581.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1582.     117,132,    /* was 13,11 XY origin relative to container TopLeft */
  1583.     &TOPAZ80,    /* font pointer or NULL for default */
  1584.     "BLACK",    /* pointer to text */
  1585.     NULL    /* next IntuiText structure */
  1586. };
  1587.  
  1588. struct Gadget __far __aligned pGadget3 = {
  1589.     &pGadget4,    /* next gadget */
  1590.     104,121,    /* origin XY of hit box relative to window TopLeft */
  1591.     67,30,    /* hit box width and height */
  1592.     NULL,    /* gadget flags */
  1593.     RELVERIFY,    /* activation flags */
  1594.     BOOLGADGET,    /* gadget type flags */
  1595.     (APTR)&pBorder2,    /* gadget border or image to be rendered */
  1596.     NULL,    /* alternate imagery for selection */
  1597.     NULL,    /* first IntuiText structure */
  1598.     NULL,    /* gadget mutual-exclude long word */
  1599.     NULL,    /* SpecialInfo structure */
  1600.     NULL,    /* user-definable data */
  1601.     NULL    /* pointer to user-definable data */
  1602. };
  1603.  
  1604. SHORT __far __aligned pBorderVectors3[] = {
  1605.     0,0,
  1606.     68,0,
  1607.     68,31,
  1608.     0,31,
  1609.     0,0
  1610. };
  1611. struct Border __far __aligned pBorder3 = {
  1612.     -1,-1,    /* XY origin relative to container TopLeft */
  1613.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1614.     5,    /* number of XY vectors */
  1615.     pBorderVectors3,    /* pointer to XY vectors */
  1616.     NULL    /* next border in list */
  1617. };
  1618.  
  1619. struct IntuiText __far __aligned pIText3 = {
  1620.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1621.     0,12,    /* XY origin relative to container TopLeft */
  1622.     &TOPAZ80,    /* font pointer or NULL for default */
  1623.     "Clear BD",    /* pointer to text */
  1624.     NULL    /* next IntuiText structure */
  1625. };
  1626.  
  1627. struct Gadget __far __aligned pGadget2 = {
  1628.     &pGadget3,    /* next gadget */
  1629.     105,82,    /* origin XY of hit box relative to window TopLeft */
  1630.     67,30,    /* hit box width and height */
  1631.     NULL,    /* gadget flags */
  1632.     RELVERIFY,    /* activation flags */
  1633.     BOOLGADGET,    /* gadget type flags */
  1634.     (APTR)&pBorder3,    /* gadget border or image to be rendered */
  1635.     NULL,    /* alternate imagery for selection */
  1636.     &pIText3,    /* first IntuiText structure */
  1637.     NULL,    /* gadget mutual-exclude long word */
  1638.     NULL,    /* SpecialInfo structure */
  1639.     NULL,    /* user-definable data */
  1640.     NULL    /* pointer to user-definable data */
  1641. };
  1642.  
  1643. UBYTE __aligned pppSIBuff[4];
  1644. struct StringInfo __aligned pppSInfo = {
  1645.     pppSIBuff,    /* buffer where text will be edited */
  1646.     NULL,    /* optional undo buffer */
  1647.     0,    /* character position in buffer */
  1648.     4,    /* maximum number of characters to allow */
  1649.     0,    /* first displayed character buffer position */
  1650.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  1651.     0,    /* Rastport of gadget */
  1652.     0,    /* initial value for integer gadgets */
  1653.     NULL    /* alternate keymap (fill in if you set the flag) */
  1654. };
  1655.  
  1656. SHORT __far __aligned pBorderVectors4[] = {
  1657.     0,0,
  1658.     55,0,
  1659.     55,16, /* was 55,24 and 0, 24 */
  1660.     0,16,
  1661.     0,0
  1662. };
  1663. struct Border __far __aligned pBorder4 = {
  1664.     -1,-1,    /* XY origin relative to container TopLeft */
  1665.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1666.     5,    /* number of XY vectors */
  1667.     pBorderVectors4,    /* pointer to XY vectors */
  1668.     NULL    /* next border in list */
  1669. };
  1670.  
  1671. struct Gadget __far __aligned pGadget1 = {
  1672.     &pGadget2,    /* next gadget */
  1673.     180,57,    /* origin XY of hit box relative to window TopLeft */
  1674.     54,15,    /* was 54, 23 hit box width and height */
  1675.     NULL,    /* gadget flags */
  1676.     RELVERIFY,    /* activation flags */
  1677.     STRGADGET,    /* gadget type flags */
  1678.     (APTR)&pBorder4,    /* gadget border or image to be rendered */
  1679.     NULL,    /* alternate imagery for selection */
  1680.     NULL,    /* first IntuiText structure */
  1681.     NULL,    /* gadget mutual-exclude long word */
  1682.     (APTR)&pppSInfo,    /* SpecialInfo structure */
  1683.     NULL,    /* user-definable data */
  1684.     NULL    /* pointer to user-definable data */
  1685. };
  1686.  
  1687. struct IntuiText __far __aligned pIText8a = {
  1688.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1689.     32,44,    /* XY origin relative to container TopLeft */
  1690.     NULL,    /* font pointer or NULL for default */
  1691.     "use space to clr a square",    /* pointer to text */
  1692.     NULL    /* next IntuiText structure */
  1693. };
  1694.  
  1695. struct IntuiText __far __aligned pIText7 = {
  1696.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1697.     26,34,    /* XY origin relative to container TopLeft */
  1698.     NULL,    /* font pointer or NULL for default */
  1699.     "Bd is updated after edit session",    /* pointer to text */
  1700.     &pIText8a    /* next IntuiText structure */
  1701. };
  1702.  
  1703. struct IntuiText __far __aligned pIText6 = {
  1704.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1705.     68,62,    /* XY origin relative to container TopLeft */
  1706.     NULL,    /* font pointer or NULL for default */
  1707.     "Piece to add",    /* pointer to text */
  1708.     &pIText7    /* next IntuiText structure */
  1709. };
  1710.  
  1711. struct IntuiText __far __aligned pIText5 = {
  1712.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1713.     59,24,    /* XY origin relative to container TopLeft */
  1714.     NULL,    /* font pointer or NULL for default */
  1715.     "pa1 for pawn at a1, etc.",    /* pointer to text */
  1716.     &pIText6    /* next IntuiText structure */
  1717. };
  1718.  
  1719. struct IntuiText __far __aligned pIText4 = {
  1720.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1721.     63,14,    /* XY origin relative to container TopLeft */
  1722.     NULL,    /* font pointer or NULL for default */
  1723.     "Enter Pieces in format",    /* pointer to text */
  1724.     &pIText5    /* next IntuiText structure */
  1725. };
  1726.  
  1727. struct NewWindow __far __aligned pNewWindowStructure1 = {
  1728.     170,30,    /* window XY origin relative to TopLeft of screen */
  1729.     300,220,    /* window width and height */
  1730.     0,TBLOCKPEN,    /* detail and block pens */
  1731.     GADGETUP+CLOSEWINDOW,    /* IDCMP flags */
  1732.     WINDOWCLOSE+SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1733.     &pGadget1,    /* first gadget in gadget list */
  1734.     NULL,    /* custom CHECKMARK imagery */
  1735.     "Edit Board",    /* window title */
  1736.     NULL,    /* custom screen pointer */
  1737.     NULL,    /* custom bitmap */
  1738.     5,5,    /* minimum width and height */
  1739.     0xffff,0xffff,    /* maximum width and height */
  1740.     CUSTOMSCREEN    /* destination screen type */
  1741. };
  1742.  
  1743. void DoEasy()
  1744. {
  1745.  
  1746.     PlayMode = 0;
  1747.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1748.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1749.     LoadBobImage(BLANKDATA);
  1750.     SortGList(rpG);
  1751.     DrawGList(rpG,vP);
  1752.     MakeVPort(GfxBase->ActiView,vP);
  1753.     MrgCop(GfxBase->ActiView);
  1754.     WaitTOF();
  1755.     RethinkDisplay();
  1756.     NewGame();
  1757. }
  1758.  
  1759. void DoAdvanced()
  1760. {
  1761.  
  1762.     PlayMode = 2;
  1763.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1764.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1765.     LoadBobImage(BLANKDATA);
  1766.     SortGList(rpG);
  1767.     DrawGList(rpG,vP);
  1768.     MakeVPort(GfxBase->ActiView,vP);
  1769.     MrgCop(GfxBase->ActiView);
  1770.     WaitTOF();
  1771.     RethinkDisplay();
  1772.     NewGame();
  1773. }
  1774.  
  1775. void DoIntermediate()
  1776. {
  1777.  
  1778.     PlayMode = 1;
  1779.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1780.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1781.     LoadBobImage(BLANKDATA);
  1782.     SortGList(rpG);
  1783.     DrawGList(rpG,vP);
  1784.     MakeVPort(GfxBase->ActiView,vP);
  1785.     MrgCop(GfxBase->ActiView);
  1786.     WaitTOF();
  1787.     RethinkDisplay();
  1788.     NewGame();
  1789. }
  1790.  
  1791.  
  1792. void
  1793. gsrand (unsigned int seed)
  1794. {
  1795.   next = seed;
  1796. }
  1797.  
  1798.  
  1799. void calc_pgm_rating()
  1800. {
  1801.  /* 34 secs on an RS/6000 which is about 2338, so to rate itself
  1802.     rating = 2338 - 75*(log2(time) - log2(34)) */
  1803.  
  1804.  int st;
  1805.  unsigned int secs;
  1806.  int rating;
  1807.  int tmpbk,Old,oldtc;
  1808.  int OldPM;
  1809.  char tstr[32],tstr2[32];
  1810.  
  1811.  OldPM = PlayMode;
  1812.  PlayMode = 2;
  1813.  tmpbk = Book;
  1814.  oldtc = TCflag;
  1815.  Old = MaxSearchDepth;
  1816.  NewGame ();
  1817.  UpdateDisplay (0, 0, 1, 0);
  1818.  MaxSearchDepth = 6;
  1819.  Book = 0;
  1820.  TCflag = 0;
  1821.  computer = computer ^ 1;
  1822.  opponent = opponent ^ 1;
  1823.  xwndw = (computer == white) ? WXWNDW : BXWNDW;
  1824.  flag.force = false;
  1825.  Sdepth = 0;
  1826.  ShowMessage("Calculating.");
  1827.  ShowMessage("Please wait.");
  1828.  SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  1829.  st = time(0L);
  1830.  SelectMove (computer, 1);
  1831.  secs = st = time(0L) - st;
  1832.  ClearPointer(wG);
  1833.  if (st<4)
  1834.   st = 4;
  1835.  st = (st - 2)/6;
  1836.  if (st > 200)
  1837.   {
  1838.    strcpy(tstr,"too slow Cannot rate");
  1839.   }
  1840.  else
  1841.   {
  1842.    if (st < 4)
  1843.     st = 4;
  1844. #ifdef PL_60
  1845.    rating = 2350 - (((75*log_e[st]) - (75*LOGE_34))/LN2);
  1846. #else /* patch level 61 */
  1847.    rating = 2350 - (((75*log_e[st]) - (75*LOGE_16))/LN2);
  1848. #endif
  1849. #ifndef _M68040 /* small mem model */
  1850.    rating -= 21;
  1851. #endif
  1852.    sprintf(tstr,"USCF %04d",rating);
  1853.   }
  1854.  Book = tmpbk;
  1855.  MaxSearchDepth = Old;
  1856.  TCflag = oldtc;
  1857.  PlayMode = OldPM;
  1858.  NewGame ();
  1859.  UpdateDisplay (0, 0, 1, 0);
  1860.  sprintf(tstr2," %d secs",secs);
  1861.  ShowMessage(tstr2);
  1862.  ShowMessage(tstr);
  1863. }
  1864.  
  1865. int DoResign()
  1866. {
  1867.  struct EasyStruct __aligned resignES = {
  1868.     sizeof (struct EasyStruct),
  1869.     0,
  1870.     "Resignation Alert",
  1871.     "Accept UChess's Resignation",
  1872.     "Yes|No",
  1873.   };
  1874.  
  1875.  ULONG __aligned iflags=0L;
  1876.  UBYTE    __aligned volname[4]={0,0,0,0};
  1877.  
  1878.  Delay(30L);
  1879.  DisplayBeep(0L);
  1880.  ResignOffered = -1;
  1881. /* return 0 if no resign accepted, yes if accepted */
  1882.  return(EasyRequest( wG, &resignES, &iflags, volname ));
  1883. }
  1884.  
  1885.  
  1886. void GetEditText(s,color)
  1887. char *s;
  1888. int *color;
  1889. { /* gets the edit string from the user */
  1890.   /* returns # for clr bd, c for change colors and pa1 to put a pawn at a1*/
  1891.   /* YOU MUST RETURN THE STRING IN ALL LOWER CASE! */
  1892.  
  1893.   int dun;
  1894.   long code,class;
  1895.   int i;
  1896.   APTR object;
  1897.   struct IntuiMessage *message;
  1898.  
  1899.   dun = 0;
  1900.   s[0] = 0;
  1901.   pppSIBuff[0] = '\0';
  1902.   ActivateGadget(&pGadget1,wGEdit,NULL);
  1903.   do {
  1904.   WaitPort(wGEdit->UserPort);
  1905.   while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
  1906.   {
  1907.    code = message->Code;
  1908.    object = message->IAddress;
  1909.    class = message->Class;
  1910.    ReplyMsg((struct Message *)message);
  1911.    if (class == CLOSEWINDOW)
  1912.     {
  1913.      strcpy(s,".");
  1914.      dun = 1;
  1915.     }
  1916.    else if (class == GADGETUP)
  1917.     { /* text */
  1918.      if (object == (APTR)&pGadget1)
  1919.       {
  1920.        if (pppSIBuff[0])
  1921.         {
  1922.          dun = 1;
  1923.          strcpy(s,pppSIBuff);
  1924.          for(i=0;i<4;i++)
  1925.           s[i] = tolower(s[i]);
  1926.         }
  1927.       }
  1928.      else if (object == (APTR)&pGadget2)
  1929.       {
  1930.        dun = 1;
  1931.        strcpy(s,"#");
  1932.       }
  1933.      else if (object == (APTR)&pGadget3)
  1934.       { /* white/black */
  1935.        if (*color == white)
  1936.         *color = black;
  1937.        else
  1938.         *color = white;
  1939.        SetDrMd(wGEdit->RPort,JAM1);
  1940.        SetAPen(wGEdit->RPort,0L);
  1941.        RectFill(wGEdit->RPort,107,124,167,145);
  1942.        if (*color == white)
  1943.         PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
  1944.        else
  1945.         PrintIText(wGEdit->RPort,&pIText2a,0L,0L); /* white label */
  1946.       }
  1947.      else if (object == (APTR)&pGadget4)
  1948.       { /* done */
  1949.        strcpy(s,".");
  1950.        dun = 1;
  1951.       }
  1952.     }
  1953.   }
  1954.  } while (!dun);
  1955.  DisplayBeep(0L);
  1956. }
  1957.  
  1958. void CloseAmigaEditWindow()
  1959. {
  1960.  struct IntuiMessage *message;
  1961.  
  1962.   while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
  1963.   {
  1964.    ReplyMsg((struct Message *)message);
  1965.   }
  1966.  CloseWindow(wGEdit);
  1967.  if (DEPTH >= 6)
  1968.   {
  1969.    SetRGB32(vP,1,tmppal[0],tmppal[1],tmppal[2]);
  1970.   }
  1971.  else
  1972.   {
  1973.    SetRGB4(vP,1,((tmppal[0]>>8)&0xf),((tmppal[0]>>4)&0xf),((tmppal[0])&0xf));
  1974.   }
  1975. }
  1976.  
  1977.  
  1978. int OpenAmigaEditWindow() /* opens a window for edit board */
  1979.  {
  1980.   if (!(wGEdit = OpenWindow(&pNewWindowStructure1)))
  1981.    {
  1982.     DisplayBeep(0L);
  1983.     return(0);
  1984.    }
  1985.  if (DEPTH >= 6)
  1986.   {
  1987.    tmppal[0] = BigColorPalette[4];
  1988.    tmppal[1] = BigColorPalette[5];
  1989.    tmppal[2] = BigColorPalette[6];
  1990.    SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  1991.   }
  1992.  else
  1993.   {
  1994.    tmppal[0] = myPalette[1];
  1995.    SetRGB4(vP,1,0xa,0xa,0xa);
  1996.   }
  1997.   pppSIBuff[0] = 0;
  1998.   pppSIBuff[3] = 0;
  1999.   PrintIText(wGEdit->RPort,&pIText4,0L,0L);
  2000.   PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
  2001.   return(1);
  2002.  }
  2003.  
  2004.  
  2005. void EnableMoveNow()
  2006. {
  2007.  if (MenuStripSet)
  2008.   {
  2009.    MoveNowOK = 1;
  2010.    OnMenu(wG,MOVENOWMENUNUM); 
  2011.   }
  2012. }
  2013.  
  2014. void DisableMoveNow()
  2015. {
  2016.  if (MenuStripSet)
  2017.   {
  2018.    MoveNowOK = 0;
  2019.    OffMenu(wG,MOVENOWMENUNUM); 
  2020.   }
  2021. }
  2022.  
  2023. int GetFileName(char *s)
  2024. {
  2025.  int tmp;
  2026.  struct FileRequester *myFileReq;
  2027.  struct TagItem  Tags[2] = {
  2028.  {ASLFR_Window,0L},
  2029.  {0,0}
  2030.  };
  2031.  
  2032.  Tags[0].ti_Data = (ULONG)wG;
  2033.  myFileReq = AllocAslRequest(ASL_FileRequest,Tags);
  2034.  if (myFileReq)
  2035.   {
  2036.    tmp = AslRequest(myFileReq,Tags);
  2037.    if (!tmp)
  2038.     {
  2039.      FreeAslRequest(myFileReq);
  2040.      return(0);
  2041.     }
  2042.    strcpy(s,myFileReq->fr_Drawer);
  2043.    if (s[0])
  2044.     {
  2045.      if ((s[strlen(s)-1] != ':')&&(s[strlen(s)-1] != '/'))
  2046.       {
  2047.        strcat(s,"/");
  2048.       }
  2049.     }
  2050.    strcat(s,myFileReq->fr_File);
  2051.    FreeAslRequest(myFileReq);
  2052.    return(0xff);
  2053.   }
  2054.  else
  2055.   return(0);
  2056. }
  2057.  
  2058. void
  2059. UpdateClocks (void)
  2060. {
  2061.   char tempstr[16];
  2062.   long ycoord;
  2063.   INTSIZE m, s;
  2064.  
  2065.   m = (INTSIZE) (et / 6000);
  2066.   s = (INTSIZE) (et - 6000 * (long) m) / 100;
  2067.   if (TCflag)
  2068.     {
  2069.       m = (INTSIZE) ((TimeControl.clock[player] - et) / 6000);
  2070.       s = (INTSIZE) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
  2071.     }
  2072.   if (m < 0)
  2073.     m = 0;
  2074.   if (s < 0)
  2075.     s = 0;
  2076.   if (player == computer)
  2077.    {
  2078.     ycoord = TIMEYCOORD1;
  2079.    }
  2080.   else
  2081.    {
  2082.     ycoord = TIMEYCOORD2;
  2083.    }
  2084.   sprintf(tempstr,"%d:%02d     ",m,s);
  2085.   Move(rpG,540,ycoord);
  2086.   mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  2087.   RectFill(rpG,540,ycoord-6,621,ycoord+5);
  2088.   mySetABPenDrMd(rpG,1,bpen,JAM1);
  2089.   Move(rpG,540,ycoord);
  2090.   Text(rpG,tempstr,strlen(tempstr));
  2091. //sprintf(tempstr,"mvslft %d",TimeControl.moves[player]);
  2092. //ShowMessage(tempstr);
  2093.   if (player == computer)
  2094.    {
  2095.     if ((!m)&&(s <= 1)&&(TCflag)&&(Sdepth > MINDEPTH))
  2096.      {
  2097.       flag.back = 1;
  2098.      }
  2099.     if ((TCflag)&&(Sdepth > MINDEPTH)&&(!m)&&
  2100.         (TimeControl.moves[player] < 6)&&(s<((TimeControl.moves[player]-1)*5)))
  2101.      {
  2102.       flag.back = true;
  2103.      }
  2104.   /*printf("prev score = %d  global_tmp_score = %d\n",previous_score,global_tmp_score);*/
  2105.     if ((TCflag) && (!trying_again) && (ResponseTime < 9999998) && (Sdepth > MINDEPTH)
  2106.         && ((et) >= ((OrigResponse<<1) + ExtraTime + 101)))
  2107.      {
  2108.       if (global_tmp_score >= (previous_score - 75))
  2109.         {
  2110. #ifdef TIMECNTRL1 /* this results in pgm taking lots of time! */
  2111.          flag.musttimeout = true;
  2112. #else /* results in  quciker timeout */
  2113.          flag.back = true;
  2114. #endif
  2115.         }
  2116.      } 
  2117.    }
  2118. }
  2119.  
  2120.  
  2121. char DisplayPromoteRequestor(void);
  2122.  
  2123. char DisplayPromoteRequestor()
  2124. {
  2125.  ULONG tmp[4];
  2126.  int dun;
  2127.  struct IntuiMessage __aligned *message;
  2128.  struct Window __aligned *wG3;
  2129.  UWORD __aligned code;
  2130.  ULONG __aligned class;
  2131.  APTR object;
  2132.  char retchar='q';
  2133.  
  2134.  if (DEPTH >= 6)
  2135.   {
  2136.    tmp[0] = BigColorPalette[4];
  2137.    tmp[1] = BigColorPalette[5];
  2138.    tmp[2] = BigColorPalette[6];
  2139.    SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2140.   }
  2141.  else
  2142.   {
  2143.    tmp[0] = myPalette[1];
  2144.    SetRGB4(vP,1,0xa,0xa,0xa);
  2145.   }
  2146.  if (!(wG3 = OpenWindow(&NewWindowStructure6)))
  2147.  {
  2148.   DisplayBeep(0L);
  2149.   return('q');
  2150.  }
  2151.  PrintIText(wG3->RPort,&aIText5,0L,0L);
  2152.  dun = 0;
  2153.  do {
  2154.  WaitPort(wG3->UserPort);
  2155.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2156.   {
  2157.    code = message->Code;
  2158.    object = message->IAddress;
  2159.    class = message->Class;
  2160.    ReplyMsg((struct Message *)message);
  2161.    dun = 1;
  2162.    if (object == (APTR)&aGadget1)
  2163.       {
  2164.        retchar = 'q';
  2165.       }
  2166.     else if (object == (APTR)&aGadget2)
  2167.       {
  2168.        retchar = 'r';
  2169.       }
  2170.     else if (object == (APTR)&aGadget3)
  2171.       {
  2172.        retchar = 'b';
  2173.       }
  2174.     else if (object == (APTR)&aGadget4)
  2175.       {
  2176.        retchar = 'n';
  2177.       }
  2178.   }
  2179.  } while (!dun);
  2180.  CloseWindow(wG3);
  2181.  if (DEPTH >= 6)
  2182.   {
  2183.    SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  2184.   }
  2185.  else
  2186.   {
  2187.    SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  2188.   }
  2189.  return(retchar);
  2190. }
  2191.  
  2192. void tFreeBitMap(struct BitMap *);
  2193. struct BitMap *tAllocBitMap(int,int,int,int,struct BitMap *);
  2194.  
  2195. struct BitMap *tAllocBitMap(wid,ht,depth,flags,friend)
  2196. int wid,ht,depth,flags;
  2197. struct BitMap *friend;
  2198. {
  2199.  int i;
  2200.  unsigned long tt;
  2201.  LONG image_data;
  2202.  WORD planes;
  2203.  struct BitMap *tmp;
  2204.  
  2205.  if (gfxversion < 39)
  2206.   {
  2207.    planes = RASSIZE(wid,ht);
  2208.    if (!(tmp = AllocMem(sizeof (struct BitMap),MEMF_CLEAR)))
  2209.     {
  2210.      return(0);
  2211.     }
  2212.    InitBitMap(tmp,depth,wid,ht);
  2213.    tt = planes*depth;
  2214.    if (!(tmp->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
  2215.     {
  2216.      FreeMem(tmp,sizeof(struct BitMap));
  2217.      return(0);
  2218.     }
  2219.    image_data = (LONG)tmp->Planes[0];
  2220.    for(i=1;i<depth;i++)
  2221.     {
  2222.      tmp->Planes[i] = (PLANEPTR) (image_data + i * planes);
  2223.     }
  2224.   }
  2225.  else
  2226.   {
  2227.    tmp = AllocBitMap(wid,ht,depth,flags,friend);
  2228.   }
  2229.  return(tmp);
  2230. }
  2231.  
  2232. void tFreeBitMap(bmap)
  2233. struct BitMap *bmap;
  2234. {
  2235.  ULONG numbytes;
  2236.  
  2237.  if (gfxversion < 39)
  2238.   {
  2239.    numbytes = bmap->Rows*bmap->BytesPerRow*bmap->Depth;
  2240.    FreeMem(bmap->Planes[0],numbytes);
  2241.    FreeMem(bmap,sizeof(struct BitMap));
  2242.   }
  2243.  else
  2244.   {
  2245.    FreeBitMap(bmap);
  2246.   }
  2247. }
  2248.  
  2249.  
  2250. void HandleEvent(object)
  2251. APTR object;
  2252. {
  2253.   if (object == (APTR)&MenuItem12) { DoAbout(); return; }
  2254.   if (object == (APTR)&MenuItem13) { LoadAGame(); return; }
  2255.   if (object == (APTR)&MenuItem14) { SaveAGame(); return; }
  2256.   if (object == (APTR)&MenuItem14a) { ListAGame(); return; }
  2257.   if (object == (APTR)&MenuItem15) { DoQuit(); return; }
  2258.   if (object == (APTR)&MenuItem9) { Go2D(); return; }
  2259.   if (object == (APTR)&MenuItem10) { EditBoard(); return; }
  2260.   if (object == (APTR)&MenuItem11) { DoReverse(); return; }
  2261.   if (object == (APTR)&MenuItem4) { DoSwap(); return; }
  2262.   if (object == (APTR)&MenuItem5) { DoAutoPlay(); return; }
  2263.   if (object == (APTR)&MenuItem6) { MoveNow(); return; }
  2264.   if (object == (APTR)&MenuItem7) { TakeBack(); return; }
  2265.   if (object == (APTR)&MenuItem8) { DoThinking(); return; }
  2266.   if (object == (APTR)&MenuItem8a) { DoShwThnk(); return; }
  2267.   if (object == (APTR)&MenuItem8aa) { DoSuper(); return; }
  2268.   if (object == (APTR)&MenuItem8ab) { DoBookToggle(); return; }
  2269.   if (object == (APTR)&MenuItem8ee) { DoAdvanced(); return; }
  2270.   if (object == (APTR)&MenuItem8dd) { DoIntermediate(); return; }
  2271.   if (object == (APTR)&MenuItem8cc) { DoEasy(); return; }
  2272.   if (object == (APTR)&MenuItem1) { DoHint(); return; }
  2273.   if (object == (APTR)&MenuItem2) { DoTest(); return; }
  2274.   if (object == (APTR)&MenuItem3) { SetTime(); return; }
  2275.   if (object == (APTR)&MenuItem3x) { calc_pgm_rating(); return; }
  2276.   if (object == (APTR)&MenuItem3r) { ChangeSearchDepth(); return; }
  2277.   if (object == (APTR)&MenuItem28) 
  2278.    { 
  2279.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  2280.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2281.     LoadBobImage(BLANKDATA);
  2282.     SortGList(rpG);
  2283.     DrawGList(rpG,vP);
  2284.     MakeVPort(GfxBase->ActiView,vP);
  2285.     MrgCop(GfxBase->ActiView);
  2286.     WaitTOF();
  2287.     RethinkDisplay();
  2288.     NewGame();
  2289.     return;
  2290.    }
  2291. }
  2292.  
  2293. /* end of PowerWindows source generation */
  2294.  
  2295. void DoAbout()
  2296. {
  2297.  int done=0;
  2298.  struct IntuiMessage __aligned *message;
  2299.  struct Window __aligned *wG3;
  2300.  ULONG class,code;
  2301.  
  2302.  if (!(wG3 = OpenWindow(&NewWindowStructure2)))
  2303.  {
  2304.   DisplayBeep(0L);
  2305.   return;
  2306.  }
  2307.  PrintIText(wG3->RPort,&IText17,0L,0L);
  2308.  do {
  2309.   WaitPort(wG3->UserPort);
  2310.   while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2311.    {
  2312.     class = message->Class;
  2313.     code = message->Code;
  2314.     ReplyMsg((struct Message *)message);
  2315.     if (class == GADGETUP)
  2316.      done = 1;
  2317.     else if (class == VANILLAKEY)
  2318.      {
  2319.       if ((code == 13)||(code == 10))
  2320.        done = 1;
  2321.      }
  2322.    }
  2323.  } while (!done);
  2324.  CloseWindow(wG3);
  2325. }
  2326.  
  2327.  
  2328. void LoadAGame(void)
  2329. {
  2330.  GetGame();
  2331. }
  2332.  
  2333. void SaveAGame(void)
  2334. {
  2335.  SaveGame();
  2336. }
  2337.  
  2338. void ListAGame(void)
  2339. {
  2340.  ListGame(0xff);
  2341. }
  2342.  
  2343. void DoQuit(void)
  2344. {
  2345.  flag.quit = true;
  2346. }
  2347.  
  2348. void Go2D(void)
  2349. {
  2350. }
  2351.  
  2352. void DoReverse(void)
  2353. {
  2354. }
  2355.  
  2356. void DoSwap(void)
  2357. {
  2358.  doswap = 1;
  2359. }
  2360.  
  2361. void DoAutoPlay(void)
  2362. {
  2363.  hint = 0;
  2364.  SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  2365.  doauto = 1;
  2366. }
  2367.  
  2368. void MoveNow(void)
  2369. {
  2370. }
  2371.  
  2372. void TakeBack(void)
  2373. {
  2374.  char mvnstr[16];
  2375.  int currpiece;
  2376.  long tmp1,tmp2;
  2377.  int r,c,l;
  2378.  
  2379.  
  2380.  doundo = 1;
  2381.  hint = 0;
  2382.  if (GameCnt <= 0)
  2383.   return;
  2384.  for (r = 7; r >= 0; r--)
  2385.   {
  2386.    for (c = 0; c <= 7; c++)
  2387.     {
  2388.       l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  2389.       if (color[l] == neutral)
  2390.     oldboard[r][c] = ' ';
  2391.       else if (color[l] == white)
  2392.     oldboard[r][c] = qxx[board[l]];
  2393.       else
  2394.     oldboard[r][c] = pxx[board[l]];
  2395.     }
  2396.   }
  2397.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  2398.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2399.  LoadBobImage(BLANKDATA);
  2400.  SortGList(rpG);
  2401.  DrawGList(rpG,vP);
  2402.  Undo();
  2403.  for (r = 7; r >= 0; r--)
  2404.     {
  2405.      for (c = 0; c <= 7; c++)
  2406.       {
  2407.         l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  2408.         if ((color[l] == neutral)&&(oldboard[r][c] != ' '))
  2409.          {
  2410.       tmp1 = r & 1L;
  2411.           tmp2 = c & 1L;
  2412.           if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  2413.            {
  2414.             BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  2415.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2416.             0xc0L,0xffL,0L);
  2417.            }
  2418.           else
  2419.            {
  2420.             BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  2421.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2422.             0xc0L,0xffL,0L);
  2423.            }
  2424.          }
  2425.         else
  2426.          {
  2427.           if (color[l] == white)
  2428.        currpiece = qxx[board[l]];
  2429.           else
  2430.        currpiece = pxx[board[l]];
  2431.           if (currpiece != oldboard[r][c])
  2432.            {
  2433.         tmp1 = r & 1L;
  2434.             tmp2 = c & 1L;
  2435.             if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  2436.              {
  2437.               BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  2438.                 RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2439.                 0xc0L,0xffL,0L);
  2440.              }
  2441.             else
  2442.              {
  2443.               BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  2444.                 RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2445.                 0xc0L,0xffL,0L);
  2446.              }
  2447.         LoadBobImage(currpiece);
  2448.             ClipBlitTrans (
  2449.         &(BobTransImage->ti_RP),    /* Source RastPort */
  2450.              0, 0,        /* Source LeftEdge, TopEdge */
  2451.              rpG,        /* Destination RastPort */
  2452.              ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
  2453.              BobTransImage->ti_IM->Width,    /* Width of Image */
  2454.              BobTransImage->ti_IM->Height,/* Height of Image */
  2455.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  2456.             BobVSprite->X = WIDTH-1-BOBWIDTH;
  2457.             BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2458.             LoadBobImage(BLANKDATA);
  2459.             SortGList(rpG);
  2460.             DrawGList(rpG,vP);
  2461.            }
  2462.          }
  2463.       }
  2464.     }
  2465.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  2466.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2467.  LoadBobImage(BLANKDATA);
  2468.  SortGList(rpG);
  2469.  DrawGList(rpG,vP);
  2470.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  2471.  RectFill(rpG,520,USERBOX,621,USERBOX+30);
  2472.  Move(rpG,520,USERBOX+6);
  2473.  if (computer != black)
  2474.   sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  2475.  else
  2476.   sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  2477.  mySetABPenDrMd(rpG,1,bpen,JAM1);
  2478.  Text(rpG,mvnstr,strlen(mvnstr));
  2479. }
  2480.  
  2481. void DoThinking(void)
  2482. {
  2483.  flag.easy = !flag.easy;
  2484. }
  2485.  
  2486. void DoShwThnk(void)
  2487. {
  2488.  flag.post = !flag.post;
  2489. }
  2490.  
  2491. void DoSuper(void)
  2492. {
  2493.  SupervisorMode = !SupervisorMode;
  2494. }
  2495.  
  2496. void DoBookToggle(void)
  2497. {
  2498.     Book = Book ? 0 : BOOKFAIL;
  2499. }
  2500.  
  2501. void DoHint(void)
  2502. {
  2503.  GiveHint();
  2504. }
  2505.  
  2506. void DoTest(void)
  2507. {
  2508.  teston = 1;
  2509. }
  2510.  
  2511. int SetAmigaDepth()
  2512. {
  2513.  int dun;
  2514.  struct IntuiMessage __aligned *message;
  2515.  struct Window __aligned *wG3;
  2516.  UWORD __aligned code;
  2517.  ULONG __aligned class;
  2518.  APTR object;
  2519.  ULONG tmp[3];
  2520.  
  2521.  if (DEPTH >= 6)
  2522.   {
  2523.    tmp[0] = BigColorPalette[4];
  2524.    tmp[1] = BigColorPalette[5];
  2525.    tmp[2] = BigColorPalette[6];
  2526.    SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2527.   }
  2528.  else
  2529.   {
  2530.    tmp[0] = myPalette[1];
  2531.    SetRGB4(vP,1,0xa,0xa,0xa);
  2532.   }
  2533.  sprintf(Gadget6SIBuff,"%d",MaxSearchDepth);
  2534.  NewWindowStructure5.FirstGadget = &Gadget6b;
  2535.  if (!(wG3 = OpenWindow(&NewWindowStructure5)))
  2536.  {
  2537.   DisplayBeep(0L);
  2538.   return(0);
  2539.  }
  2540.  Move(wG3->RPort,66,39);
  2541.  Text(wG3->RPort,"Depth",5);
  2542.  ActivateGadget(&Gadget6,wG3,NULL);
  2543.  dun = 0;
  2544.  do {
  2545.  WaitPort(wG3->UserPort);
  2546.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2547.   {
  2548.    code = message->Code;
  2549.    object = message->IAddress;
  2550.    class = message->Class;
  2551.    ReplyMsg((struct Message *)message);
  2552. #ifdef SELECTIVEBB
  2553.    if (object != (APTR)&Gadget6b)
  2554.       {
  2555.        dun = 1;
  2556.       }
  2557. #else
  2558.    dun = 1;
  2559. #endif
  2560.   }
  2561.  } while (!dun);
  2562.  CloseWindow(wG3);
  2563.  if (DEPTH >= 6)
  2564.   {
  2565.    SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  2566.   }
  2567.  else
  2568.   {
  2569.    SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  2570.   }
  2571.  dun = atoi(Gadget6SIBuff);
  2572.  if (dun > (MAXDEPTH-1))
  2573.   dun = MAXDEPTH -1;
  2574.  if (dun < MINDEPTH)
  2575.   dun = MINDEPTH;
  2576.  NewWindowStructure5.FirstGadget = &Gadget6;
  2577.  return(dun);
  2578. }
  2579.  
  2580. void SetTime(void)
  2581. {
  2582.  int dun;
  2583.  char str[128];
  2584.  struct IntuiMessage __aligned *message;
  2585.  struct Window __aligned *wG3;
  2586.  UWORD __aligned code;
  2587.  ULONG __aligned class;
  2588.  APTR object;
  2589.  ULONG tmp[3];
  2590.  struct Gadget *tg;
  2591.  
  2592.  if (DEPTH >= 6)
  2593.   {
  2594.    tmp[0] = BigColorPalette[4];
  2595.    tmp[1] = BigColorPalette[5];
  2596.    tmp[2] = BigColorPalette[6];
  2597.    SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2598.   }
  2599.  else
  2600.   {
  2601.    tmp[0] = myPalette[1];
  2602.    SetRGB4(vP,1,0xa,0xa,0xa);
  2603.   }
  2604.  sprintf(Gadget6SIBuff,"%d",TCmoves);
  2605.  sprintf(Gadget8SIBuff,"%d",(TCminutes));
  2606.  if (!(wG3 = OpenWindow(&NewWindowStructure5)))
  2607.  {
  2608.   DisplayBeep(0L);
  2609.   return;
  2610.  }
  2611.  PrintIText(wG3->RPort,&IText46,0L,0L);
  2612.  ActivateGadget(&Gadget6,wG3,NULL);
  2613.  dun = 0;
  2614.  do {
  2615.  WaitPort(wG3->UserPort);
  2616.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2617.   {
  2618.    code = message->Code;
  2619.    object = message->IAddress;
  2620.    class = message->Class;
  2621.    ReplyMsg((struct Message *)message);
  2622.    if (object != (APTR)&Gadget9)
  2623.       {
  2624.        if (object == (APTR)&Gadget6)
  2625.         {
  2626.          tg = &Gadget8;
  2627.          ActivateGadget(tg,wG3,NULL);
  2628.         }
  2629.        else if (object == (APTR)&Gadget8)
  2630.         dun = 1;
  2631.       }
  2632.      else
  2633.       {
  2634.        dun = 1;
  2635.       }
  2636.   }
  2637.  } while (!dun);
  2638.  CloseWindow(wG3);
  2639.  if (DEPTH >= 6)
  2640.   {
  2641.    SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  2642.   }
  2643.  else
  2644.   {
  2645.    SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  2646.   }
  2647.  strcpy(str,Gadget6SIBuff);
  2648.  strcat (str," ");
  2649.  strcat(str,Gadget8SIBuff);
  2650.  SelectLevel(str);
  2651.  et = 0;
  2652.  dun = player;
  2653.  player = white;
  2654.  UpdateClocks();
  2655.  player = black;
  2656.  UpdateClocks();
  2657.  player = dun;
  2658. }
  2659.  
  2660.  
  2661.  
  2662. void DisplayError(str)
  2663. char *str;
  2664. {
  2665.  struct IntuiMessage __aligned *message;
  2666.  struct Window __aligned *wG3;
  2667.  
  2668.  if (!(wG3 = OpenWindow(&NewWindowStructure2)))
  2669.  {
  2670.   DisplayBeep(0L);
  2671.   return;
  2672.  }
  2673.  Move(wG3->RPort,2,25);
  2674.  Text(wG3->RPort,str,strlen(str));
  2675.  WaitPort(wG3->UserPort);
  2676.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2677.   ReplyMsg((struct Message *)message);
  2678.  CloseWindow(wG3);
  2679. }
  2680.  
  2681. struct Library *LhBase;
  2682. struct LhBuffer *myLHBuffer;
  2683.  
  2684. int LoadBobData(void);
  2685. void FreeBobData(void);
  2686. int InitmyGels(void);
  2687. void CloseGels(void);
  2688.  
  2689.  
  2690. void LoadBobImage(piece)
  2691. long piece; /* loads bob with pieces image */
  2692. {
  2693.  int i;
  2694.  UWORD *temp;
  2695.  LONG image_data;
  2696.  WORD planes = RASSIZE (BOBWIDTH, BOBHEIGHT);
  2697.  
  2698.  if (piece == BLANKDATA)
  2699.   {
  2700.    temp = BlankImageData;
  2701.   }
  2702.  else if (piece >= 'a') /* white pieces */
  2703.   {
  2704.    if (piece == 'p')
  2705.     temp = WhiteImageData[0];
  2706.    else if (piece == 'n')
  2707.     temp = WhiteImageData[1];
  2708.    else if (piece == 'b')
  2709.     temp = WhiteImageData[2];
  2710.    else if (piece == 'r')
  2711.     temp = WhiteImageData[3];
  2712.    else if (piece == 'q')
  2713.     temp = WhiteImageData[4];
  2714.    else if (piece == 'k')
  2715.     temp = WhiteImageData[5];
  2716.   }
  2717.  else /* black pieces */
  2718.   {
  2719.    if (piece == 'P')
  2720.     temp = BlackImageData[0];
  2721.    else if (piece == 'N')
  2722.     temp = BlackImageData[1];
  2723.    else if (piece == 'B')
  2724.     temp = BlackImageData[2];
  2725.    else if (piece == 'R')
  2726.     temp = BlackImageData[3];
  2727.    else if (piece == 'Q')
  2728.     temp = BlackImageData[4];
  2729.    else if (piece == 'K')
  2730.     temp = BlackImageData[5];
  2731.   }
  2732.  BobImage.ImageData = BobVSprite->ImageData = temp;
  2733.  image_data = (LONG) BobImage.ImageData;
  2734.  /* Map the image data to planes */
  2735.  for (i = 0L; i < BOBDEPTH; ++i)
  2736.   BobTransImage->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
  2737.  temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
  2738.  TheBob->ImageShadow = BobVSprite->CollMask = temp;
  2739.  temp += ((BOBHEIGHT+2)*BOBWIDINW);
  2740.  BobVSprite->BorderLine = temp;
  2741.  BobImage.ImageData = BobVSprite->ImageData;
  2742.  BobTransImage->ti_sBM->Planes[0] = (char *)TheBob->ImageShadow;
  2743.  for (i = 1; i < BOBDEPTH; i++)
  2744.    BobTransImage->ti_sBM->Planes[i] = BobTransImage->ti_sBM->Planes[0];
  2745.  lastpiece = piece;
  2746. }
  2747.  
  2748. int LoadBobData()
  2749. {
  2750.  USHORT __aligned len;
  2751.  long __aligned templong;
  2752.  BPTR fh;
  2753.  UBYTE *srcbuf;
  2754.  int i;
  2755.  
  2756.  if (!(srcbuf = AllocMem(BOBBLOCKSIZE,0L)))
  2757.   {
  2758.    return(0);
  2759.   }
  2760.  if (DEPTH < 6)
  2761.   {
  2762.    if (!(fh = Open("uchess:Pieces.lzw",MODE_OLDFILE)))
  2763.     {
  2764.     return(0);
  2765.    }
  2766.   }
  2767.  else if (FasterDisplay)
  2768.   {
  2769.    if (!(fh = Open("uchess:Pieces64.lzw",MODE_OLDFILE)))
  2770.     {
  2771.     return(0);
  2772.    }
  2773.   }
  2774.  else
  2775.   {
  2776.    if (!(fh = Open("uchess:Pieces256.lzw",MODE_OLDFILE)))
  2777.     {
  2778.     return(0);
  2779.    }
  2780.   }
  2781.  if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
  2782.   {
  2783.    DisplayError("Cannot open lh.lib\n");
  2784.    return(0);
  2785.   }
  2786.  if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
  2787.   {
  2788.    DisplayError("Cannot Create Buffer\n");
  2789.    CloseLibrary(LhBase);
  2790.    return(0);
  2791.   }
  2792.  for(i=0;i<6;i++)
  2793.   {
  2794.    if (Read(fh,(char *)&len,2L) != 2L)
  2795.     {
  2796.      Close(fh);
  2797.      return(0);
  2798.     }
  2799.    templong = len;
  2800.    if (Read(fh,srcbuf,templong) != templong)
  2801.     {
  2802.      Close(fh);
  2803.      return(0);
  2804.     }
  2805.    if (!(WhiteImageData[i] = 
  2806.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  2807.     {
  2808.      return(0);
  2809.     }
  2810.    LoadBobImage(piecechar[i]);
  2811.    myLHBuffer->lh_Src = (APTR)srcbuf;
  2812.    myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
  2813.    myLHBuffer->lh_SrcSize = templong;
  2814.    myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
  2815.    LhDecode(myLHBuffer);
  2816.    InitMasks(BobVSprite);
  2817.    if (Read(fh,(char *)&len,2L) != 2L)
  2818.     {
  2819.      Close(fh);
  2820.      return(0);
  2821.     }
  2822.    templong = len;
  2823.    if (Read(fh,srcbuf,templong) != templong)
  2824.     {
  2825.      Close(fh);
  2826.      return(0);
  2827.     }
  2828.    if (!(BlackImageData[i] = 
  2829.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  2830.     {
  2831.      return(0);
  2832.     }
  2833.    LoadBobImage(piecechar[i+6]);
  2834.    myLHBuffer->lh_Src = (APTR)srcbuf;
  2835.    myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
  2836.    myLHBuffer->lh_SrcSize = templong;
  2837.    myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
  2838.    LhDecode(myLHBuffer);
  2839.    InitMasks(BobVSprite);
  2840.   }
  2841.  Close(fh);
  2842.  FreeMem(srcbuf,BOBBLOCKSIZE);
  2843.  DeleteBuffer(myLHBuffer);
  2844.  CloseLibrary(LhBase);
  2845.  LoadBobImage(BLANKDATA);
  2846.  return(1);
  2847. }
  2848.  
  2849. void FreeBobData()
  2850. {
  2851.  int i;
  2852.  
  2853.  for(i=0;i<6;i++)
  2854.   {
  2855.    FreeMem((char *)WhiteImageData[i],BOBBLOCKSIZE);
  2856.    FreeMem((char *)BlackImageData[i],BOBBLOCKSIZE);
  2857.   }
  2858.  FreeMem((char *)BlankImageData,BOBBLOCKSIZE);
  2859. }
  2860.  
  2861. int InitmyGels()
  2862. {
  2863.  
  2864. #ifdef EXTRAINIT
  2865.  struct BitMap __aligned tmpBitMap;
  2866. #endif
  2867.  int i;
  2868.  UWORD *temp;
  2869.  
  2870.  if (!(SpriteHead = (struct VSprite *)
  2871.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  2872.   {
  2873.    return(0);
  2874.   }
  2875.  if (!(SpriteTail = (struct VSprite *)
  2876.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  2877.   {
  2878.    return(0);
  2879.   }
  2880.  if (!(BobVSprite = (struct VSprite *)
  2881.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  2882.   {
  2883.    return(0);
  2884.   }
  2885.  if (!(TheBob = (struct Bob *)
  2886.        AllocMem(sizeof(struct Bob),MEMF_PUBLIC|MEMF_CLEAR)))
  2887.   {
  2888.    return(0);
  2889.   }
  2890.  if (!(myGelsInfo = (struct GelsInfo *)
  2891.        AllocMem(sizeof(struct GelsInfo),MEMF_PUBLIC|MEMF_CLEAR)))
  2892.   {
  2893.    return(0);
  2894.   }
  2895.  if (!(myGelsInfo->nextLine = (WORD *)AllocMem(sizeof(WORD)*32,
  2896.     MEMF_PUBLIC|MEMF_CLEAR)))
  2897.   {
  2898.    return(0);
  2899.   }
  2900.  if (!(myGelsInfo->lastColor = (WORD **)AllocMem(sizeof(WORD)*32,
  2901.     MEMF_PUBLIC|MEMF_CLEAR)))
  2902.   {
  2903.    return(0);
  2904.   }
  2905.  if (!(myGelsInfo->collHandler = (struct collTable *)
  2906.     AllocMem(sizeof(struct collTable),MEMF_PUBLIC|MEMF_CLEAR)))
  2907.   {
  2908.    return(0);
  2909.   }
  2910.  if (!(TheBob->SaveBuffer = (WORD *)
  2911.     AllocMem(sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH,MEMF_CHIP|MEMF_CLEAR)))
  2912.   {
  2913.    return(0);
  2914.   }
  2915.  if (!(temp = BobVSprite->ImageData = 
  2916.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  2917.     {
  2918.      return(0);
  2919.     }
  2920.  BlankImageData = temp;
  2921.  temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
  2922.  TheBob->ImageShadow = BobVSprite->CollMask = temp;
  2923.  temp += ((BOBHEIGHT+2)*BOBWIDINW);
  2924.  BobVSprite->BorderLine = temp;
  2925. #ifdef DBL_BUFF
  2926.  if (!(TheBob->DBuffer = (struct DBufPacket *)AllocMem
  2927.         (sizeof(struct DBufPacket),MEMF_CHIP|MEMF_CLEAR)))
  2928.     {
  2929.      return(0);
  2930.     }
  2931.  if (!(TheBob->DBuffer->BufBuffer = 
  2932.        (WORD *)AllocRaster(BOBWIDTH,BOBHEIGHT*BOBDEPTH)))
  2933.   {
  2934.      return(0);
  2935.   }
  2936. #endif
  2937.  
  2938.  BOBPLANEPICK = 1;
  2939.  for(i=0;i<DEPTH;i++)
  2940.   {
  2941.    BOBPLANEPICK *= 2;
  2942.   }
  2943.  BOBPLANEPICK--;
  2944.  BobImage.LeftEdge = 0;
  2945.  BobImage.TopEdge = 0;
  2946.  BobImage.Width = BOBWIDTH;
  2947.  BobImage.Height = BOBHEIGHT;
  2948.  BobImage.Depth = BOBDEPTH; 
  2949.  BobImage.ImageData = BobVSprite->ImageData;
  2950.  BobImage.PlanePick = BOBPLANEPICK;
  2951.  BobImage.PlaneOnOff = BOBPLANEONOFF;
  2952.  BobImage.NextImage = NULL;
  2953.  if (!(BobTransImage = AllocTransImage(&BobImage)))
  2954.   {
  2955.    return(0);
  2956.   }
  2957.  
  2958.  myGelsInfo->leftmost = COLA;
  2959.  myGelsInfo->rightmost = COLH+BOBWIDTH+1;
  2960.  myGelsInfo->topmost = ROW8;
  2961.  myGelsInfo->bottommost = ROW1+BOBHEIGHT+1;
  2962.  rpG->GelsInfo = myGelsInfo;
  2963.  InitGels((struct VSprite *)SpriteHead,SpriteTail,myGelsInfo);
  2964.  WaitTOF();
  2965.  BobVSprite->Flags = SAVEBACK | OVERLAY;
  2966.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  2967.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2968.  BobVSprite->Height = BOBHEIGHT;
  2969.  BobVSprite->Width = BOBWIDINW;
  2970.  BobVSprite->Depth = BOBDEPTH;
  2971.  BobVSprite->MeMask = BOBMEMASK;
  2972.  BobVSprite->HitMask = BOBHITMASK;
  2973.  BobVSprite->VSBob = TheBob;
  2974.  BobVSprite->PlanePick = BOBPLANEPICK;
  2975.  BobVSprite->PlaneOnOff = BOBPLANEONOFF;  
  2976.  BobVSprite->VUserExt = 0;
  2977.  TheBob->BobVSprite = BobVSprite;
  2978.  
  2979.  if (!LoadBobData())
  2980.   {
  2981.    DisplayError("Cannot Load BOB data\n");
  2982.   }
  2983.  
  2984.  
  2985.  InitMasks(BobVSprite);
  2986.  AddBob(TheBob,rpG);
  2987.  
  2988. #ifdef EXTRAINIT
  2989.  InitBitMap(&tmpBitMap,DEPTH,BOBWIDTH,BOBHEIGHT);
  2990.  tmpBitMap.Planes[0] = (char *)TheBob->SaveBuffer;
  2991.  tt = BOBWIDINW*BOBHEIGHT*sizeof(WORD);
  2992.  for(i=1;i<DEPTH;i++)
  2993.   tmpBitMap.Planes[i] = tmpBitMap.Planes[0] + (tt*i);
  2994.  BltBitMap(myBitMap,BobVSprite->X,BobVSprite->Y,&tmpBitMap,0L,0L,BOBWIDTH,BOBHEIGHT,0xc0L,0xffL,0L);
  2995. #endif
  2996.  
  2997.  WaitTOF();
  2998.  MakeScreen(sC);
  2999.  RethinkDisplay();
  3000.  SortGList(rpG);
  3001.  DrawGList(rpG,vP);
  3002.  MakeVPort(GfxBase->ActiView,vP);
  3003.  MrgCop(GfxBase->ActiView);
  3004.  WaitTOF();
  3005.  SortGList(rpG);
  3006.  DrawGList(rpG,vP);
  3007.  MakeVPort(GfxBase->ActiView,vP);
  3008.  MrgCop(GfxBase->ActiView);
  3009.  WaitTOF();
  3010.  SortGList(rpG);
  3011.  DrawGList(rpG,vP);
  3012.  MakeVPort(GfxBase->ActiView,vP);
  3013.  MrgCop(GfxBase->ActiView);
  3014.  WaitTOF();
  3015.  MakeScreen(sC);
  3016.  RethinkDisplay();
  3017.  WaitTOF();
  3018.  return(1);
  3019. }
  3020.  
  3021. void CloseGels()
  3022. {
  3023.      RemIBob(TheBob,rpG,vP);
  3024.      FreeBobData();
  3025.    
  3026. #ifdef DBL_BUFF
  3027.    FreeRaster((PLANEPTR)TheBob->DBuffer->BufBuffer,BOBWIDTH,BOBHEIGHT*BOBDEPTH);
  3028.    FreeMem((char *)TheBob->DBuffer,sizeof(struct DBufPacket));
  3029. #endif
  3030.    FreeTransImage(BobTransImage);
  3031.    FreeMem((char *)TheBob->SaveBuffer,
  3032.      sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH);
  3033.    FreeMem((char *)myGelsInfo->collHandler,sizeof(struct collTable));
  3034.    FreeMem((char *)myGelsInfo->lastColor,sizeof(WORD)*32);
  3035.    FreeMem((char *)myGelsInfo->nextLine,sizeof(WORD)*32);
  3036.    FreeMem((char *)myGelsInfo,sizeof(struct GelsInfo));
  3037.    FreeMem((char *)TheBob,sizeof(struct Bob));
  3038.    FreeMem((char *)BobVSprite,sizeof(struct VSprite));
  3039.    FreeMem((char *)SpriteTail,sizeof(struct VSprite));
  3040.    FreeMem((char *)SpriteHead,sizeof(struct VSprite));
  3041. }
  3042.  
  3043. struct TransImage *
  3044. AllocTransImage (struct Image * im)
  3045. {
  3046.     if (im)
  3047.     {
  3048.     LONG msize = sizeof (struct TransImage);
  3049.     struct TransImage *ti;
  3050.  
  3051.     if (ti = (struct TransImage *) AllocMem (msize, MEMF_CLEAR))
  3052.     {
  3053.         LONG image_data = (LONG) im->ImageData;
  3054.         UWORD depth = im->Depth;
  3055.         UWORD width = im->Width;
  3056.         UWORD height = im->Height;
  3057.         WORD planes = RASSIZE (width, height);
  3058.         WORD i;
  3059.  
  3060.         /* Remember the image */
  3061.         ti->ti_IM = im;
  3062.  
  3063.         /* Initialize the Image bitmap */
  3064.         InitBitMap (&ti->ti_BM, depth, width, height);
  3065.  
  3066.         /* Map the image data to planes */
  3067.         for (i = 0L; i < depth; ++i)
  3068.         ti->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
  3069.  
  3070.         /* Initialize the Image rastport */
  3071.         InitRastPort (&ti->ti_RP);
  3072.         ti->ti_RP.BitMap = &ti->ti_BM;
  3073.  
  3074.         if (ti->ti_sBM = AllocShadowBM (depth, width, height))
  3075.         {
  3076.         if (ti->ti_sRP = AllocShadowRP (ti->ti_sBM))
  3077.         {
  3078.             return (ti);
  3079.         }
  3080.         FreeShadowBM (ti->ti_sBM);
  3081.         }
  3082.         FreeMem ((APTR) ti, msize);
  3083.     }
  3084.     }
  3085.  
  3086.     return (NULL);
  3087. }
  3088.  
  3089. VOID
  3090. FreeTransImage (struct TransImage * ti)
  3091. {
  3092.  
  3093.     if (ti)
  3094.     {
  3095.     LONG msize = sizeof (struct TransImage);
  3096.  
  3097.     /* Free the shadow RastPort */
  3098.     FreeShadowRP (ti->ti_sRP);
  3099.  
  3100.     /* Free the shadow BitMap */
  3101.     FreeShadowBM (ti->ti_sBM);
  3102.  
  3103.     /* Free the temporary buffer */
  3104.     FreeMem ((APTR) ti, msize);
  3105.     }
  3106. }
  3107.  
  3108. VOID
  3109. FreeShadowBM (struct BitMap *sbm)
  3110. {
  3111.  
  3112.     if (sbm)
  3113.     {
  3114.  
  3115. #ifdef ALLOCFORREAL
  3116.     LONG msize;
  3117.  
  3118.     msize = RASSIZE (8 * (sbm->BytesPerRow), sbm->Rows);
  3119.  
  3120.  
  3121.  
  3122.     if (sbm->Planes[0])
  3123.     {
  3124.         FreeMem ((APTR)sbm->Planes[0], msize);
  3125.     }
  3126. #else
  3127.  
  3128.     FreeMem ((APTR)sbm, sizeof (struct BitMap));
  3129. #endif
  3130.     }
  3131. }
  3132.  
  3133. VOID
  3134. FreeShadowRP (struct RastPort *srp)
  3135. {
  3136.  
  3137.     if (srp)
  3138.     {
  3139.     FreeMem (srp, sizeof (struct RastPort));
  3140.     }
  3141. }
  3142.  
  3143. struct BitMap *
  3144. AllocShadowBM (UWORD depth, UWORD width, UWORD height)
  3145. {
  3146.     LONG msize = sizeof (struct BitMap);
  3147.     struct BitMap *bm;
  3148.     WORD i;
  3149.  
  3150.     /* Allocate a bitmap */
  3151.     if (bm = (struct BitMap *) AllocMem (msize, MEMF_CLEAR))
  3152.     {
  3153. #ifdef ALLOCFORREAL
  3154.     LONG rsize = RASSIZE (width, height);
  3155. #endif
  3156.  
  3157.     /* Initialize the bitmap */
  3158.     InitBitMap (bm, depth, width, height);
  3159.  
  3160. #ifdef ALLOCFORREAL
  3161.     /* Allocate one plane */
  3162.     if (bm->Planes[0] = (PLANEPTR) AllocMem (rsize, MEMF_CHIP | MEMF_CLEAR))
  3163.     {
  3164.         /* All planes point to the first plane */
  3165.         for (i = 1; i < depth; i++)
  3166.         bm->Planes[i] = bm->Planes[0];
  3167.  
  3168.         return (bm);
  3169.     }
  3170.  
  3171.     FreeMem ((APTR) bm, msize);
  3172. #else
  3173.      bm->Planes[0] = (char *)TheBob->ImageShadow;
  3174.      for (i = 1; i < depth; i++)
  3175.     bm->Planes[i] = bm->Planes[0];
  3176.      return (bm);
  3177. #endif
  3178.     }
  3179.     return (NULL);
  3180. }
  3181.  
  3182. struct RastPort *
  3183. AllocShadowRP (struct BitMap *bm)
  3184. {
  3185.     LONG msize = sizeof (struct RastPort);
  3186.     struct RastPort *rp;
  3187.  
  3188.     /* Allocate a RastPort */
  3189.     if (rp = (struct RastPort *) AllocMem (msize, MEMF_CHIP))
  3190.     {
  3191.     /* Initialize the new RastPort */
  3192.     InitRastPort (rp);
  3193.  
  3194.     /* Point the RastPort's BitMap... */
  3195.     rp->BitMap = bm;
  3196.     }
  3197.  
  3198.     return (rp);
  3199. }
  3200.  
  3201.  
  3202. VOID
  3203. ClipBlitTrans (
  3204.     struct RastPort *rp,    /* source RastPort */
  3205.     WORD sx, WORD sy,        /* source top-left edge */
  3206.     struct RastPort *drp,    /* destination RastPort */
  3207.     WORD dx, WORD dy,        /* destination top-left edge */
  3208.     WORD width, WORD height,    /* width & height of image to blit */
  3209.     struct RastPort *Srp)    /* shadow RastPort */
  3210. {
  3211.  
  3212.     /* make the shadow */
  3213.     ClipBlit (rp, sx, sy, Srp, 0, 0, width, height, 0xe0);
  3214.     ClipBlit (Srp, 0, 0, drp, dx, dy, width, height, 0x20); /* blit cookie cutter outline */
  3215.     ClipBlit (rp, sx, sy, drp, dx, dy, width, height, 0xe0); /* now fill in image */
  3216. }
  3217.  
  3218.  
  3219. int LoadFullBitMap(void);
  3220.  
  3221. int LoadFullBitMap()
  3222. {
  3223.  char errstr[40];
  3224.  char fname[80];
  3225.  long count;
  3226.  USHORT len;
  3227.  char *srcbuf;
  3228.  ULONG tt;
  3229.  BPTR fh;
  3230.  BPTR __aligned fp;
  3231.  struct BitMap *tmpBitMap;
  3232.  struct FileInfoBlock __aligned *myFileInfoBlock;
  3233.  
  3234.  if (DEPTH < 6)
  3235.   strcpy(fname,"uchess:Chess.lzw");
  3236.  else if (FasterDisplay)
  3237.   strcpy(fname,"uchess:Chess64.lzw");
  3238.  else
  3239.   strcpy(fname,"uchess:Chess256.lzw");
  3240.  
  3241.  
  3242.   if (!(myFileInfoBlock = 
  3243.      (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock),MEMF_PUBLIC)))
  3244.    {
  3245.      DisplayError("No Mem now for finfo block");
  3246.      return(0);
  3247.    }
  3248.   if (!(fp = Lock(fname,ACCESS_READ)))
  3249.    {
  3250.      FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3251.      return(0);
  3252.    }
  3253.   if (!(Examine(fp,myFileInfoBlock)))
  3254.    {
  3255.      DisplayError("Cannot get finfo");
  3256.      UnLock(fp);
  3257.      FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3258.      return(0);
  3259.    }
  3260.   UnLock(fp);
  3261.   count = myFileInfoBlock->fib_Size - 2L;
  3262.   FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3263.  
  3264.  
  3265. /* before unpacking the bitmap, save the titlebar area in a tmp bitmap */
  3266.  if (!(tmpBitMap = tAllocBitMap(WIDTH,MENUBARHT,DEPTH,BMF_CLEAR,myBitMap)))
  3267.   {
  3268.    return(0);
  3269.   }
  3270.  BltBitMap(myBitMap,0,0,tmpBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
  3271.  if (!(srcbuf = AllocMem(count,0L)))
  3272.   {
  3273.    sprintf(errstr,"Cannot allocate lharc %d byte buffer",count);
  3274.    DisplayError(errstr);
  3275.    return(0);
  3276.   }
  3277.  if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
  3278.   {
  3279.    DisplayError("Cannot open lh.lib");
  3280.    return(0);
  3281.   }
  3282.  if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
  3283.   {
  3284.    DisplayError("Cannot Create Buffer");
  3285.    CloseLibrary(LhBase);
  3286.    return(0);
  3287.   }
  3288.  
  3289. #ifdef GG
  3290.  if (DEPTH < 6)
  3291.   { 
  3292. #endif
  3293.    if (!(fh = Open(fname,MODE_OLDFILE)))
  3294.     {
  3295.      DisplayError("Cannot open chess file");
  3296.      return(0);
  3297.     }
  3298.    if (Read(fh,(char *)&len,2L) != 2L)
  3299.     {
  3300.      DisplayError("Cannot read chess file");
  3301.      Close(fh);
  3302.      return(0);
  3303.     }
  3304.    if (Read(fh,srcbuf,count) != count)
  3305.     {
  3306.      DisplayError("Cannot read chess file2");
  3307.      Close(fh);
  3308.      return(0);
  3309.     }
  3310.    Close(fh);
  3311.     
  3312.    myLHBuffer->lh_Src = (APTR)srcbuf;
  3313.    myLHBuffer->lh_Dst = (APTR)myBitMap->Planes[0];
  3314.    myLHBuffer->lh_SrcSize = count;
  3315.    tt = WIDTH/8L;
  3316.    tt = tt*HEIGHT;
  3317.    tt = tt*DEPTH;
  3318.    myLHBuffer->lh_DstSize = tt;
  3319.    LhDecode(myLHBuffer);
  3320. #ifdef GG
  3321.   }
  3322.  else
  3323.   { /* depth == 8 */
  3324.    if (!(fh = Open(fname,MODE_OLDFILE)))
  3325.     {
  3326.      return(0);
  3327.     }
  3328.    for(i=0;i<8;i++)
  3329.     {
  3330.       if (Read(fh,(char *)&len,2L) != 2L)
  3331.        {
  3332.         Close(fh);
  3333.         return(0);
  3334.        }
  3335.       templen = len;
  3336.       if (Read(fh,srcbuf,templen) != templen)
  3337.        {
  3338.         Close(fh);
  3339.         return(0);
  3340.        }
  3341.       myLHBuffer->lh_Src = (APTR)srcbuf;
  3342.       myLHBuffer->lh_Dst = (APTR)myBitMap->Planes[i];
  3343.       myLHBuffer->lh_SrcSize = templen;
  3344.       tt = WIDTH/8L;
  3345.       tt = tt*HEIGHT;
  3346.       myLHBuffer->lh_DstSize = tt;
  3347.       LhDecode(myLHBuffer);
  3348.     }
  3349.    Close(fh);
  3350.   } /* DEPTH == 8 clause */
  3351. #endif
  3352.  
  3353.  FreeMem(srcbuf,count); 
  3354.  DeleteBuffer(myLHBuffer);
  3355.  CloseLibrary(LhBase);
  3356.  BltBitMap(tmpBitMap,0,0,myBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
  3357.  tFreeBitMap(tmpBitMap);
  3358.  
  3359.  mySetABPenDrMd(rpG,1,bpen,JAM1);
  3360.  Move(rpG,511,COMPUTERBOX-10);
  3361. #ifdef _M68040
  3362.  strcpy(fname,"UChess Pro:");
  3363. #else
  3364.  strcpy(fname,"UChess Jr.:");
  3365. #endif
  3366.  Text(rpG,fname,strlen(fname));
  3367.  Move(rpG,511,USERBOX-10);
  3368.  strcpy(fname,"Puny Human:");
  3369.  Text(rpG,fname,strlen(fname));
  3370.  BltBitMap(myBitMap,COLB,ROW5,WhiteBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3371.  BltBitMap(myBitMap,COLA,ROW5,BlackBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3372.  RethinkDisplay();
  3373.  return(1);
  3374. }
  3375.  
  3376.  
  3377. int mAllocBitMap(void);
  3378.  
  3379. int mAllocBitMap()
  3380. {
  3381.  REG USHORT i;
  3382.  unsigned long tt;
  3383.  ULONG temp2;
  3384.  char *temp;
  3385.  
  3386.  if (DEPTH < 6)
  3387.   {
  3388.  if (!(myBitMap = (struct BitMap *)AllocMem(sizeof(struct BitMap),0L)))
  3389.   {
  3390.    return(0);
  3391.   }
  3392.  InitBitMap(myBitMap,DEPTH,WIDTH,HEIGHT);
  3393.  tt = WIDTH/8L;
  3394.  tt = tt*HEIGHT;
  3395.  tt = tt*DEPTH;
  3396.  if (!(myBitMap->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
  3397.   {
  3398.    FreeMem((char *)myBitMap,sizeof(struct BitMap));
  3399.    return(0);
  3400.   }
  3401.  Orig_PlanePtr = (char *)myBitMap->Planes[0];
  3402.  temp = (char *)myBitMap->Planes[0];
  3403.  temp2 = WIDTH/8L;
  3404.  temp2 *= HEIGHT;
  3405.  for (i=1;i<DEPTH;i++)
  3406.   {
  3407.    temp += temp2;
  3408.    myBitMap->Planes[i] = (PLANEPTR)temp;
  3409.   }
  3410.  }
  3411.  else /* 8 bit screen */
  3412.  {
  3413.   if (!(myBitMap = AllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
  3414.                     0L)))
  3415.    {
  3416.     return(0);
  3417.    }
  3418.  }
  3419.  NewScreenStructure.CustomBitMap = myBitMap;
  3420.  if (!(WhiteBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3421.                         BMF_CLEAR,myBitMap)))
  3422.   {
  3423.    return(0);
  3424.   }
  3425.  if (!(BlackBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3426.                         BMF_CLEAR,myBitMap)))
  3427.   {
  3428.    return(0);
  3429.   }
  3430.  return(1);
  3431. }
  3432.  
  3433. void FreeTheBitMap(void);
  3434.  
  3435. void FreeTheBitMap()
  3436. {
  3437.  tFreeBitMap(BlackBitMap);
  3438.  tFreeBitMap(WhiteBitMap);
  3439.  if (DEPTH < 6)
  3440.   {
  3441.     tt = WIDTH / 8L;
  3442.     tt *= HEIGHT;
  3443.     tt *= DEPTH;
  3444.     FreeMem(Orig_PlanePtr,tt);
  3445.     FreeMem((char *)myBitMap,sizeof(struct BitMap));
  3446.   }
  3447.  else
  3448.   {
  3449.     FreeBitMap(myBitMap);
  3450.   }
  3451. }
  3452.  
  3453. void AmigaShutDown(void);
  3454. int AmigaStartup(void);
  3455.  
  3456. int AmigaStarted = 0;
  3457.  
  3458. int AmigaStartup()
  3459. {
  3460.     flag.post = false;
  3461.         if (!(myTextFont = OpenFont(&TOPAZ80)))
  3462.          {
  3463.       return(0);
  3464.          }
  3465.         if (gfxversion < 39)
  3466.          DEPTH = 4;
  3467.         else
  3468.          {
  3469.           if (v15Khz)
  3470.            myTagList[0].ti_Data = HIRES|LACE|PAL_MONITOR_ID;
  3471.           if (Super72)
  3472.            myTagList[0].ti_Data = (SUPER72_MONITOR_ID | SUPERLACE_KEY);
  3473.           NewScreenStructure2.Type |= NS_EXTENDED;
  3474.           NewScreenStructure2.Extension = myTagList;
  3475.           NewScreenStructure2.Height = 480;
  3476.           NewScreenStructure2.Depth = 8; 
  3477.           NewScreenStructure2.BlockPen = 251;
  3478.       if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
  3479.            {
  3480.             CloseScreen(sC);
  3481.             DEPTH = 8;
  3482.            }
  3483.           else
  3484.            {
  3485.             myTagList[0].ti_Data = HIRES|LACE|PAL_MONITOR_ID;
  3486.         if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
  3487.              {
  3488.               CloseScreen(sC);
  3489.               DEPTH = 8;
  3490.              }
  3491.             else
  3492.              {
  3493.               myTagList[0].ti_Data = HIRES|LACE;
  3494.               DEPTH = 4;
  3495.              }
  3496.            }
  3497.          }
  3498.         if (DEPTH == 8)
  3499.          {
  3500.           if (FasterDisplay)
  3501.            {
  3502.             DEPTH = 6;
  3503.             MBLOCKPEN = 61;
  3504.             BACKGNDTEXTCOLOR = 57;
  3505.            }
  3506.           else
  3507.            {
  3508.             MBLOCKPEN = 251;
  3509.             BACKGNDTEXTCOLOR = 0xe0;
  3510.            }
  3511.       TIMEYCOORD1 = 120;
  3512.       TIMEYCOORD2 = 230;
  3513.           USERBOX=168;
  3514.           SYSTEMBOX = USERBOX + 112;
  3515.           SYSBOXLEN = 102;
  3516.           COMPUTERBOX=60;
  3517.           BOBDEPTH = DEPTH;
  3518.           ROW8 = 24;
  3519.           BOBHEIGHT = 55;
  3520.           HEIGHT = 480;
  3521.           NewScreenStructure.Type |= NS_EXTENDED;
  3522.           NewScreenStructure.Extension = myTagList;
  3523.           NewScreenStructure.Height = HEIGHT;
  3524.           NewScreenStructure.Depth = DEPTH;
  3525.           NewScreenStructure.BlockPen = MBLOCKPEN;
  3526.           NewWindowStructure1.Height = HEIGHT;
  3527.           NewWindowStructure1.MaxHeight = HEIGHT;
  3528.           NewWindowStructure1.BlockPen = MBLOCKPEN;
  3529.           NewWindowStructure2.BlockPen = MBLOCKPEN;
  3530.           NewWindowStructure5.BlockPen = MBLOCKPEN;
  3531.           NewWindowStructure6.BlockPen = MBLOCKPEN;
  3532.           pNewWindowStructure1.BlockPen = MBLOCKPEN;
  3533.           Border6.FrontPen = Border7.FrontPen = 
  3534.           Border9.FrontPen = Border1.FrontPen = MBLOCKPEN;
  3535.           aBorder1.FrontPen = aBorder2.FrontPen = 
  3536.           aBorder3.FrontPen = aBorder4.FrontPen = 
  3537.           pBorder1.FrontPen = pBorder2.FrontPen = 
  3538.           pBorder3.FrontPen = pBorder4.FrontPen = MBLOCKPEN;
  3539.           pIText1.FrontPen = 
  3540.           pIText2.FrontPen = 
  3541.           pIText2a.FrontPen = 
  3542.           pIText3.FrontPen = 
  3543.           pIText4.FrontPen = 
  3544.           pIText5.FrontPen = 
  3545.           pIText6.FrontPen = 
  3546.           pIText7.FrontPen = 
  3547.           pIText8a.FrontPen = 
  3548.           IText93.FrontPen = 
  3549.           IText47.FrontPen = 
  3550.           IText46.FrontPen = 
  3551.           IText37.FrontPen = 
  3552.           IText1.FrontPen = 
  3553.           IText1r.FrontPen = 
  3554.           IText2.FrontPen = 
  3555.           IText2x.FrontPen = 
  3556.           IText3.FrontPen = 
  3557.           IText4.FrontPen = 
  3558.           IText4aa.FrontPen = 
  3559.           IText4ab.FrontPen = 
  3560.           IText4cc.FrontPen = 
  3561.           IText4dd.FrontPen = 
  3562.           IText4ee.FrontPen = 
  3563.           IText4a.FrontPen = 
  3564.           IText5.FrontPen = 
  3565.           IText6.FrontPen = 
  3566.           IText7.FrontPen = 
  3567.           IText8.FrontPen = 
  3568.           IText9.FrontPen = 
  3569.           IText10.FrontPen = 
  3570.           IText11.FrontPen = 
  3571.           IText12.FrontPen = 
  3572.           IText13.FrontPen = 
  3573.           IText13a.FrontPen = 
  3574.           IText14.FrontPen = 
  3575.           IText15.FrontPen = 
  3576.           IText16.FrontPen = 
  3577.           IText22.FrontPen = 
  3578.           IText21.FrontPen = 
  3579.           IText20.FrontPen = 
  3580.           IText19.FrontPen = 
  3581.           IText18.FrontPen = 
  3582.           aIText1.FrontPen = 
  3583.           aIText2.FrontPen = 
  3584.           aIText3.FrontPen = 
  3585.           aIText4.FrontPen = 
  3586.           aIText5.FrontPen = 
  3587.           IText17.FrontPen = MBLOCKPEN;
  3588.          }
  3589.         if (!(mAllocBitMap()))
  3590.          {
  3591.           CloseFont(myTextFont);
  3592.           return(0);
  3593.          }
  3594.         RowArray[0] = ROW1;
  3595.         RowArray[1] = ROW2;
  3596.         RowArray[2] = ROW3;
  3597.         RowArray[3] = ROW4;
  3598.         RowArray[4] = ROW5;
  3599.         RowArray[5] = ROW6;
  3600.         RowArray[6] = ROW7;
  3601.         RowArray[7] = ROW8;
  3602.     if (!(sC = OpenScreen((struct NewScreen *)&NewScreenStructure)))
  3603.          {
  3604.           FreeTheBitMap();
  3605.           CloseFont(myTextFont);
  3606.           return(0);
  3607.          }
  3608.         vP = &sC->ViewPort;
  3609.         if (DEPTH >= 6)
  3610.          {
  3611.           if (!FasterDisplay)
  3612.          LoadRGB32(&(sC->ViewPort),BigColorPalette);
  3613.           else
  3614.          LoadRGB32(&(sC->ViewPort),Big64Palette);
  3615.          }
  3616.         else
  3617.      LoadRGB4(&(sC->ViewPort),myPalette,16);
  3618.     NewWindowStructure1.Screen = sC;
  3619.     pNewWindowStructure1.Screen = sC;
  3620.     NewWindowStructure2.Screen = sC;
  3621.     NewWindowStructure5.Screen = sC;
  3622.     NewWindowStructure6.Screen = sC;
  3623.     wG = OpenWindow(&NewWindowStructure1);    /* open the window */
  3624.     if ( wG == NULL )
  3625.      {
  3626.       CloseScreen(sC);
  3627.           CloseFont(myTextFont);
  3628.           FreeTheBitMap();
  3629.           return(0);
  3630.      }
  3631.         globalsignalset = WINDOWSIGNAL;
  3632.     rpG = wG->RPort;    /* get a rastport pointer for the window */
  3633.     SetFont(rpG,myTextFont);
  3634.         Delay(25L); /* crashes from wb if I do not do this! */
  3635.         if (!LoadFullBitMap())
  3636.          {
  3637.          return(0);
  3638.          }
  3639. /*      SetMenuStrip(wG,&MenuList1);    /* attach any Menu */
  3640.         SetDrMd(rpG,JAM1);
  3641.         if (!InitmyGels())
  3642.          {
  3643.       CloseScreen(sC);
  3644.           CloseFont(myTextFont);
  3645.           FreeTheBitMap();
  3646.           return(0);
  3647.          }
  3648.         else
  3649.          {
  3650.            AmigaStarted = 1;
  3651.            if (gfxversion > 38)
  3652.          bpen = GetBPen(rpG);
  3653.        return(1);
  3654.          }
  3655. }
  3656.  
  3657.  
  3658.  
  3659. void AmigaShutDown()
  3660. {
  3661.  struct IntuiMessage __aligned *message;
  3662.  
  3663.         ClearPointer(wG);
  3664.     CloseGels();
  3665.         while(message = (struct IntuiMessage *)GetMsg(wG->UserPort))
  3666.          ReplyMsg((struct Message *)message);
  3667.         CloseWindow(wG);
  3668.         CloseScreen(sC);
  3669.         FreeTheBitMap();
  3670.         CloseFont(myTextFont);
  3671. /*        system("delete >nil: CLP58.#?");*/
  3672. }
  3673.  
  3674. void ShowMessage(str)
  3675. char *str;
  3676. {
  3677.  char tstr[16];
  3678.  int done = 0;
  3679.  int i=0;
  3680.  struct BitMap *tempBitMap;
  3681.  int j,k,lim;
  3682.  int ycoord;
  3683.  
  3684.  if (str[strlen(str)-1] == '\n')
  3685.   {
  3686.    str[strlen(str)-1] = 0;
  3687.   }
  3688.  if (!(tempBitMap = tAllocBitMap(160,160,DEPTH,BMF_CLEAR,myBitMap)))
  3689.   {
  3690.    DisplayBeep(0L);
  3691.    Delay(10L);
  3692.    DisplayBeep(0L);
  3693.    Delay(15L);
  3694.    DisplayBeep(0L);
  3695.    Delay(25L);
  3696.    DisplayBeep(0L);
  3697.    return;
  3698.   }
  3699.  ycoord = SYSTEMBOX+6;
  3700. /* scroll down 3 lines (30 pixels) */
  3701.  BltBitMap(myBitMap,510,SYSTEMBOX,tempBitMap,0L,0L,621-510+1,SYSBOXLEN,0xc0L,0xffL,0L);
  3702.  BltBitMap(tempBitMap,0,0,myBitMap,510,SYSTEMBOX+30,621-510+1,SYSBOXLEN-30,0xc0L,0xffL,0L);
  3703.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  3704.  RectFill(rpG,510,SYSTEMBOX-1,621,SYSTEMBOX+29);
  3705.  mySetABPenDrMd(rpG,1,bpen,JAM1);
  3706.  do {
  3707.  j = i;
  3708.  if (strlen(str) <= 14)
  3709.   {
  3710.    done = 1;
  3711.    strcpy(tstr,str);
  3712.   }
  3713.  else
  3714.   {
  3715.    lim = j + 14;
  3716.    if (lim >= strlen(str))
  3717.     {
  3718.      done = 1;
  3719.      lim = strlen(str);
  3720.     }
  3721.    for(k=0;i<lim;i++,k++)
  3722.     tstr[k] = str[i];
  3723.    tstr[k] = 0;
  3724.   }
  3725.  Move(rpG,510,ycoord); /* was 509,ycord */
  3726.  ycoord += 10;
  3727.  Text(rpG,tstr,strlen(tstr));
  3728.  } while (!done);
  3729.  tFreeBitMap(tempBitMap);
  3730. }
  3731.  
  3732.  
  3733.  
  3734. void DisplayComputerMove(str)
  3735. char *str;
  3736. {
  3737.  char tstr[16];
  3738.  int done = 0;
  3739.  int i=0;
  3740.  int j,k,lim;
  3741.  int ycoord;
  3742.  
  3743.  if (str[strlen(str)-1] == '\n')
  3744.   {
  3745.    str[strlen(str)-1] = 0;
  3746.   }
  3747.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  3748.  RectFill(rpG,520,COMPUTERBOX,621,COMPUTERBOX+30);
  3749.  ycoord = COMPUTERBOX+6;
  3750.  do {
  3751.  j = i;
  3752.  if (strlen(str) <= 12)
  3753.   {
  3754.    done = 1;
  3755.    strcpy(tstr,str);
  3756.   }
  3757.  else
  3758.   {
  3759.    lim = j + 12;
  3760.    if (lim >= strlen(str))
  3761.     {
  3762.      done = 1;
  3763.      lim = strlen(str);
  3764.     }
  3765.    for(k=0;i<lim;i++,k++)
  3766.     tstr[k] = str[i];
  3767.    tstr[k] = 0;
  3768.   }
  3769.  mySetABPenDrMd(rpG,1,bpen,JAM1);
  3770.  Move(rpG,520,ycoord);
  3771.  ycoord += 10;
  3772.  Text(rpG,tstr,strlen(tstr));
  3773.  } while (!done);
  3774. }
  3775.  
  3776. void DoLegalMove(str)
  3777. char *str;
  3778. {
  3779.  long mpiece;
  3780.  char piece;
  3781.  int r,c,l;
  3782.  int ecol,erow,scol,srow,side,tmp1,tmp2,incrx,incry,i;
  3783.  
  3784.    SortGList(rpG);
  3785.    DrawGList(rpG,vP);
  3786.    MakeVPort(GfxBase->ActiView,vP);
  3787.    MrgCop(GfxBase->ActiView);
  3788.    RemIBob(TheBob,rpG,vP);
  3789.    SortGList(rpG);
  3790.    DrawGList(rpG,vP);
  3791.    MakeVPort(GfxBase->ActiView,vP);
  3792.    MrgCop(GfxBase->ActiView);
  3793.    r = str[3] - '1';
  3794.    c = str[2] - 'a';
  3795.    tmp1 = r & 1;
  3796.    tmp2 = c & 1;
  3797.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  3798.     {
  3799.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  3800.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  3801.             0xc0L,0xffL,0L);
  3802.     }
  3803.    else
  3804.     {
  3805.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  3806.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  3807.             0xc0L,0xffL,0L);
  3808.     }
  3809.    MakeVPort(GfxBase->ActiView,vP);
  3810.    MrgCop(GfxBase->ActiView);
  3811.    RethinkDisplay();
  3812.    WaitTOF();
  3813.    l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  3814.    if ((color[l] == neutral))
  3815.     {
  3816.      ExitChess();
  3817.      return;
  3818.     }
  3819.    else if (color[l] == white)
  3820.     piece = qxx[board[l]]; /* white are lower case pieces */
  3821.    else
  3822.     piece = pxx[board[l]]; /* black are upper case pieces */
  3823.    if ((DestRow == 7)||(!DestRow))
  3824.     { /* possible promotion */
  3825.       mpiece = piece;
  3826.       LoadBobImage(mpiece);
  3827.     }
  3828.    ClipBlitTrans (
  3829.         &(BobTransImage->ti_RP),    /* Source RastPort */
  3830.              0, 0,        /* Source LeftEdge, TopEdge */
  3831.              rpG,        /* Destination RastPort */
  3832.              ColArray[DestCol],RowArray[DestRow],/* Destination LeftEdge, TopEdge */
  3833.              BobTransImage->ti_IM->Width,    /* Width of Image */
  3834.              BobTransImage->ti_IM->Height,/* Height of Image */
  3835.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  3836.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  3837.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  3838.    LoadBobImage(BLANKDATA);
  3839.    AddBob(TheBob,rpG);
  3840.    SortGList(rpG);
  3841.    DrawGList(rpG,vP);
  3842.    MakeVPort(GfxBase->ActiView,vP);
  3843.    MrgCop(GfxBase->ActiView);
  3844.    if (piece >= 'a')
  3845.     {
  3846.      mpiece = 'r';
  3847.      srow = 0;
  3848.      erow = 0;
  3849.      side = white;
  3850.      if (str[2] == 'g') /* king side white */
  3851.       {
  3852.        scol = 7;
  3853.        ecol = 5;
  3854.       }
  3855.      else
  3856.       {
  3857.        ecol = 3;
  3858.        scol = 0;
  3859.       }
  3860.     }
  3861.    else
  3862.     {
  3863.      mpiece = 'R';
  3864.      srow = 7;
  3865.      erow = 7;
  3866.      side = black;
  3867.      if (str[2] == 'g') /* king side black */
  3868.       {
  3869.        scol = 7;
  3870.        ecol = 5;
  3871.       }
  3872.      else
  3873.       {
  3874.        ecol = 3;
  3875.        scol = 0;
  3876.       }
  3877.     }
  3878.    if (Castled[side])
  3879.     {
  3880.      Castled[side] = 0;
  3881.      tmp1 = srow & 1;
  3882.      tmp2 = scol & 1;
  3883.      if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  3884.       {
  3885.        BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  3886.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  3887.             0xc0L,0xffL,0L);
  3888.       }
  3889.      else
  3890.       {
  3891.        BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  3892.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  3893.             0xc0L,0xffL,0L);
  3894.       }
  3895.      BobVSprite->X = ColArray[scol];
  3896.      BobVSprite->Y = RowArray[srow];
  3897.      SortGList(rpG);
  3898.      DrawGList(rpG,vP);
  3899.      MakeVPort(GfxBase->ActiView,vP);
  3900.      MrgCop(GfxBase->ActiView);
  3901.      LoadBobImage(mpiece);
  3902.      SortGList(rpG);
  3903.      DrawGList(rpG,vP);
  3904.      MakeVPort(GfxBase->ActiView,vP);
  3905.      MrgCop(GfxBase->ActiView);
  3906.      incry = (RowArray[erow] - RowArray[srow])/8;
  3907.      incrx = (ColArray[ecol] - ColArray[scol])/8;
  3908.      for(i=0;i<8;i++)
  3909.       {
  3910.        BobVSprite->X += incrx;
  3911.        BobVSprite->Y += incry;
  3912.        SortGList(rpG);
  3913.        DrawGList(rpG,vP);
  3914.        MakeVPort(GfxBase->ActiView,vP);
  3915.        MrgCop(GfxBase->ActiView);
  3916.       }
  3917.      RemIBob(TheBob,rpG,vP);
  3918.      SortGList(rpG);
  3919.      DrawGList(rpG,vP);
  3920.      MakeVPort(GfxBase->ActiView,vP);
  3921.      MrgCop(GfxBase->ActiView);
  3922.      ClipBlitTrans (
  3923.             &(BobTransImage->ti_RP),    /* Source RastPort */
  3924.                  0, 0,        /* Source LeftEdge, TopEdge */
  3925.                  rpG,        /* Destination RastPort */
  3926.                  ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  3927.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  3928.                  BobTransImage->ti_IM->Height,/* Height of Image */
  3929.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  3930.      LoadBobImage(BLANKDATA);
  3931.      AddBob(TheBob,rpG);
  3932.      MakeVPort(GfxBase->ActiView,vP);
  3933.      MrgCop(GfxBase->ActiView);
  3934.     }
  3935.    else /* check EnPassant */
  3936.     {
  3937.      side ^= 1;
  3938.      if (myEnPassant[side])
  3939.       {
  3940.        myEnPassant[side] = 0;
  3941.        scol = str[2] - 'a';
  3942.        if (str[3] == '3') /* white is removed from bd at 4*/
  3943.         {
  3944.          srow = 3;
  3945.         }
  3946.        else /* black is removed at pos 5 */
  3947.         {
  3948.          srow = 4;
  3949.         }
  3950.        tmp1 = srow & 1;
  3951.        tmp2 = scol & 1;
  3952.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  3953.         {
  3954.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  3955.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  3956.             0xc0L,0xffL,0L);
  3957.         }
  3958.        else
  3959.         {
  3960.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  3961.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  3962.             0xc0L,0xffL,0L);
  3963.         }
  3964.       }
  3965.     }
  3966. }
  3967.  
  3968. void DrawAmigaBoard()
  3969. {
  3970.  int r,c,l,tmp1,tmp2;
  3971.  int piece;
  3972.  
  3973.  LoadBobImage(BLANKDATA);
  3974.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  3975.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  3976.  SortGList(rpG);
  3977.  DrawGList(rpG,vP);
  3978.  RemIBob(TheBob,rpG,vP);
  3979.  SortGList(rpG);
  3980.  DrawGList(rpG,vP);
  3981.  for(r=0;r<8;r++)
  3982.   for(c=0;c<8;c++)
  3983.    {
  3984.        tmp1 = r & 1;
  3985.        tmp2 = c & 1;
  3986.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  3987.         {
  3988.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  3989.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  3990.             0xc0L,0xffL,0L);
  3991.         }
  3992.        else
  3993.         {
  3994.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  3995.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  3996.             0xc0L,0xffL,0L);
  3997.         }    
  3998.     l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  3999.     if (color[l] == white)
  4000.      piece = qxx[board[l]]; /* white are lower case pieces */
  4001.     else
  4002.      piece = pxx[board[l]]; /* black are upper case pieces */
  4003.     if (color[l] != neutral)
  4004.      {
  4005.       BobVSprite->X = ColArray[c];
  4006.       BobVSprite->Y = RowArray[r];
  4007.       LoadBobImage(piece);
  4008.       ClipBlitTrans (
  4009.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4010.              0, 0,        /* Source LeftEdge, TopEdge */
  4011.              rpG,        /* Destination RastPort */
  4012.              ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
  4013.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4014.              BobTransImage->ti_IM->Height,/* Height of Image */
  4015.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4016.      }
  4017.    }
  4018.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  4019.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4020.  LoadBobImage(BLANKDATA);
  4021.  AddBob(TheBob,rpG);
  4022. }
  4023.  
  4024.  
  4025. void GetOperatorEntry(str)
  4026. char *str;
  4027. {
  4028.  char __aligned PromoteChar;
  4029.  char mvnstr[16];
  4030.  ULONG signals;
  4031.  char __aligned tempstr[40];
  4032.  struct IntuiMessage __aligned *message;
  4033.  long done=0;
  4034.  long done2;
  4035.  int ilen=0;
  4036.  int r,c,l,piece;
  4037.  long __aligned class,code;
  4038.  int MouseX,MouseY;
  4039.  long tmp1,tmp2;
  4040.  
  4041.  
  4042.  
  4043.  ClearPointer(wG);
  4044.  if (CheckIllegal)
  4045.   {
  4046.    CheckIllegal = 0;
  4047.    if (IllegalMove)
  4048.     { /* put guy back! */
  4049.       IllegalMove = 0;
  4050.       RemIBob(TheBob,rpG,vP);
  4051.       SortGList(rpG);
  4052.       DrawGList(rpG,vP);
  4053.       MakeVPort(GfxBase->ActiView,vP);
  4054.       MrgCop(GfxBase->ActiView);
  4055.       ClipBlitTrans (
  4056.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4057.              0, 0,        /* Source LeftEdge, TopEdge */
  4058.              rpG,        /* Destination RastPort */
  4059.              ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  4060.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4061.              BobTransImage->ti_IM->Height,/* Height of Image */
  4062.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4063.       BobVSprite->X = WIDTH-1-BOBWIDTH;
  4064.       BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4065.       LoadBobImage(BLANKDATA);
  4066.       AddBob(TheBob,rpG);
  4067.       MakeVPort(GfxBase->ActiView,vP);
  4068.       MrgCop(GfxBase->ActiView);
  4069.     }
  4070.   }
  4071.  while (message = (struct IntuiMessage *)GetMsg(wG->UserPort))
  4072.    {
  4073.      ReplyMsg((struct Message *)message);
  4074.    }
  4075.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4076.  RectFill(rpG,520,USERBOX,621,USERBOX+30);
  4077.  Move(rpG,520,USERBOX+6);
  4078.  if (computer != black)
  4079.   sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  4080.  else
  4081.   sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  4082.  mySetABPenDrMd(rpG,1,bpen,JAM1);
  4083.  Text(rpG,mvnstr,strlen(mvnstr));
  4084.  tempstr[0] = 0;
  4085.  PromoteChar = 0;
  4086.  OnMenu(wG,SHOWMENUNUM); 
  4087.  OnMenu(wG,SUPERMENUNUM); 
  4088.  OnMenu(wG,THINKMENUNUM); 
  4089.  OnMenu(wG,BOOKMENUNUM); 
  4090.  do {
  4091.  if (!globalmessage_valid)
  4092.   signals = Wait(globalsignalset);
  4093.  if ((signals & WINDOWSIGNAL)||(globalmessage_valid))
  4094.  {
  4095.   message = (struct IntuiMessage *)1;
  4096.   while (message)
  4097.   {
  4098.   if (!globalmessage_valid)
  4099.    message = (struct IntuiMessage *)GetMsg(wG->UserPort);
  4100.   if ((message)||(globalmessage_valid))
  4101.    {
  4102.         if (!globalmessage_valid)
  4103.          {
  4104.       class = message->Class;
  4105.       code = message->Code;
  4106.           MouseX = message->MouseX;
  4107.           MouseY = message->MouseY;
  4108.       ReplyMsg((struct Message *)message);
  4109.          }
  4110.         else
  4111.          {
  4112.       class = globalmessage.Class;
  4113.       code = globalmessage.Code;
  4114.           MouseX = globalmessage.MouseX;
  4115.           MouseY = globalmessage.MouseY;
  4116.           globalmessage_valid = 0L;
  4117.          }
  4118.     if ( class == MENUPICK )    /* MenuItems */
  4119.          {
  4120.        HandleEvent((APTR)ItemAddress(&MenuList1,code));
  4121.           if (flag.quit) 
  4122.            done = 1;
  4123.           else
  4124.            {
  4125.             if (teston)
  4126.              {
  4127.               done = 1;
  4128.               teston = 0;
  4129.               strcpy(tempstr,"test");
  4130.              }
  4131.             else if (doswap)
  4132.              {
  4133.               done = 1;
  4134.               doswap = 0;
  4135.               strcpy(tempstr,"switch");
  4136.              }
  4137.             else if (doauto)
  4138.              {
  4139.               done = 1;
  4140.               doauto = 0;
  4141.               strcpy(tempstr,"both");
  4142.              }
  4143.             else if (doundo)
  4144.              {
  4145.               done = 1;
  4146.               doundo = 0;
  4147.               strcpy(tempstr,"help");
  4148.              }
  4149.            }
  4150.          }
  4151.     else if (class == RAWKEY)
  4152.      {
  4153.           if (code < 80)
  4154.            {
  4155.           code = cookedchar[code];
  4156.           if ((code == 13)||(code == 10))
  4157.        {
  4158.             done = 1;
  4159.        }
  4160.           else if ((code == 7)&&(ilen)) /* backspace */
  4161.            {
  4162.             tempstr[strlen(tempstr)-1] = '\0';
  4163.             mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4164.             RectFill(rpG,520,USERBOX,621,USERBOX+30);
  4165.             mySetABPenDrMd(rpG,1,bpen,JAM1);
  4166.             Move(rpG,520,USERBOX+6);
  4167.             if (computer != black)
  4168.              sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  4169.             else
  4170.             sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  4171.             Text(rpG,mvnstr,strlen(mvnstr));
  4172.             Text(rpG,tempstr,strlen(tempstr));
  4173.             ilen--;
  4174.            }
  4175.           else if ((isalnum(code)||(code == '-')||(code == '/')) && (strlen(tempstr) < 12))
  4176.            {
  4177.             tempstr[ilen] = tolower(code);
  4178.             mySetABPenDrMd(rpG,1,bpen,JAM1);
  4179.             Move(rpG,520,USERBOX+6);
  4180.             ilen++;
  4181.             tempstr[ilen] = 0;
  4182.             if (computer != black)
  4183.              sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  4184.             else
  4185.             sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  4186.             Text(rpG,mvnstr,strlen(mvnstr));
  4187.             Text(rpG,tempstr,strlen(tempstr));
  4188.            }
  4189.           } /* code < 80 */
  4190.      }
  4191.         else if ((class == MOUSEBUTTONS)&&(!(flag.quit || flag.mate || flag.force)))
  4192.          {
  4193.           if ((code == SELECTDOWN) && 
  4194.               ((MouseY <= (ROW1+SQUAREHEIGHT)) && (MouseY >= ROW8) && (MouseX <= (COLH+BOBWIDTH)) &&
  4195.                (MouseX >= COLA)))
  4196.            {
  4197.             if (MouseX < COLB)
  4198.              OrigCol = 0;
  4199.             else if (MouseX < COLC)
  4200.              OrigCol = 1;
  4201.             else if (MouseX < COLD)
  4202.              OrigCol = 2;
  4203.             else if (MouseX < COLE)
  4204.              OrigCol = 3;
  4205.             else if (MouseX < COLF)
  4206.              OrigCol = 4;
  4207.             else if (MouseX < COLG)
  4208.              OrigCol = 5;
  4209.             else if (MouseX < COLH)
  4210.              OrigCol = 6;
  4211.             else 
  4212.              OrigCol = 7;
  4213.             if (MouseY < ROW7)
  4214.              OrigRow = 7;
  4215.             else if (MouseY < ROW6)
  4216.              OrigRow = 6;
  4217.             else if (MouseY < ROW5)
  4218.              OrigRow = 5;
  4219.             else if (MouseY < ROW4)
  4220.              OrigRow = 4;
  4221.             else if (MouseY < ROW3)
  4222.              OrigRow = 3;
  4223.             else if (MouseY < ROW2)
  4224.              OrigRow = 2;
  4225.             else if (MouseY < ROW1)
  4226.              OrigRow = 1;
  4227.             else 
  4228.              OrigRow = 0;
  4229.             tmp1 = OrigRow & 1L;
  4230.             tmp2 = OrigCol & 1L;
  4231.             done2 = 0;
  4232.             r = OrigRow;
  4233.             c = OrigCol;
  4234.             l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  4235.             if ((color[l] == neutral)||(opponent != color[l]))
  4236.              {
  4237.               done2 = 1;
  4238.              }
  4239.             else if (color[l] == white)
  4240.              piece = qxx[board[l]]; /* white are lower case pieces */
  4241.             else
  4242.              piece = pxx[board[l]]; /* black are upper case pieces */
  4243.             if (!done2)
  4244.              {
  4245.               if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4246.                {
  4247.                 BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[OrigCol],
  4248.             RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
  4249.             0xc0L,0xffL,0L);
  4250.                }
  4251.               else
  4252.                {
  4253.                 BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[OrigCol],
  4254.             RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
  4255.             0xc0L,0xffL,0L);
  4256.                }
  4257.               BobVSprite->X = WIDTH-1-BOBWIDTH;
  4258.               BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4259.               LoadBobImage(BLANKDATA);
  4260.               SortGList(rpG);
  4261.               DrawGList(rpG,vP);
  4262.               MakeVPort(GfxBase->ActiView,vP);
  4263.               MrgCop(GfxBase->ActiView);
  4264.               CheckIllegal = 1;
  4265.               IllegalMove = 0;
  4266.  /* NOW POSITION BOB AND LOAD IN ITS CORRECT PIECE IMAGE */
  4267.           LoadBobImage(piece);
  4268.               BobVSprite->X = MouseX - 24;
  4269.               BobVSprite->Y = MouseY - 16;
  4270.               SortGList(rpG);
  4271.               DrawGList(rpG,vP);
  4272.               MakeVPort(GfxBase->ActiView,vP);
  4273.               MrgCop(GfxBase->ActiView);
  4274.              }
  4275.             ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags | INTUITICKS);
  4276.             do {
  4277.             signals = Wait(globalsignalset);
  4278.             if (signals & WINDOWSIGNAL)
  4279.              {
  4280.               while ( (message = (struct IntuiMessage *)
  4281.           GetMsg(wG->UserPort) ))
  4282.               {
  4283.           class = message->Class;
  4284.           code = message->Code;
  4285.               MouseX = message->MouseX;
  4286.               MouseY = message->MouseY;
  4287.           ReplyMsg((struct Message *)message);
  4288.               if (!done2)
  4289.                {
  4290.               if ((class == MOUSEBUTTONS)&&(code == SELECTUP))
  4291.                { /* now try and make the move */
  4292.                 done2 = 1;
  4293.         if ((MouseX > (COLH+SQUAREWIDTH)) || (MouseX < COLA) ||
  4294.                     (MouseY < ROW8) || (MouseY > (ROW1+BOBHEIGHT)))
  4295.                  { /* Put the Piece Back */
  4296.                    BobVSprite->X = WIDTH-1-BOBWIDTH;
  4297.                    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4298.                    tmp1 = lastpiece;
  4299.            LoadBobImage(BLANKDATA);
  4300.                    SortGList(rpG);
  4301.                    DrawGList(rpG,vP);
  4302.                    RemIBob(TheBob,rpG,vP);
  4303.                    SortGList(rpG);
  4304.                    DrawGList(rpG,vP);
  4305.                    MakeVPort(GfxBase->ActiView,vP);
  4306.                    MrgCop(GfxBase->ActiView);
  4307.            LoadBobImage(tmp1);
  4308.                    ClipBlitTrans (
  4309.               &(BobTransImage->ti_RP),    /* Source RastPort */
  4310.               0, 0,        /* Source LeftEdge, TopEdge */
  4311.               rpG,        /* Destination RastPort */
  4312.               ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  4313.               BobTransImage->ti_IM->Width,    /* Width of Image */
  4314.               BobTransImage->ti_IM->Height,/* Height of Image */
  4315.               BobTransImage->ti_sRP);    /* Shadow RastPort */
  4316.                    BobVSprite->X = WIDTH-1-BOBWIDTH;
  4317.                    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4318.                    LoadBobImage(BLANKDATA);
  4319.                    AddBob(TheBob,rpG);
  4320.                    SortGList(rpG);
  4321.                    DrawGList(rpG,vP);
  4322.                    MakeVPort(GfxBase->ActiView,vP);
  4323.                    MrgCop(GfxBase->ActiView);
  4324.                  }
  4325.                 else
  4326.                  {
  4327.                   done = 1; /* try the move */
  4328.                   if (MouseX < COLB)
  4329.                    DestCol = 0;
  4330.                   else if (MouseX < COLC)
  4331.                    DestCol = 1;
  4332.                   else if (MouseX < COLD)
  4333.                    DestCol = 2;
  4334.                   else if (MouseX < COLE)
  4335.                    DestCol = 3;
  4336.                   else if (MouseX < COLF)
  4337.                    DestCol = 4;
  4338.                   else if (MouseX < COLG)
  4339.                    DestCol = 5;
  4340.                   else if (MouseX < COLH)
  4341.                    DestCol = 6;
  4342.                   else 
  4343.                    DestCol = 7;
  4344.                   if (MouseY < ROW7)
  4345.                    DestRow = 7;
  4346.                   else if (MouseY < ROW6)
  4347.                    DestRow = 6;
  4348.                   else if (MouseY < ROW5)
  4349.                    DestRow = 5;
  4350.                   else if (MouseY < ROW4)
  4351.                    DestRow = 4;
  4352.                   else if (MouseY < ROW3)
  4353.                    DestRow = 3;
  4354.                   else if (MouseY < ROW2)
  4355.                    DestRow = 2;
  4356.                   else if (MouseY < ROW1)
  4357.                    DestRow = 1;
  4358.                   else 
  4359.                    DestRow = 0;
  4360.                   if ((DestRow == OrigRow) && (DestCol == OrigCol))
  4361.                    {
  4362.                     done = 0;
  4363.             tmp1 = lastpiece;
  4364.             LoadBobImage(BLANKDATA);
  4365.                     BobVSprite->X = WIDTH-1-BOBWIDTH;
  4366.                     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4367.                     SortGList(rpG);
  4368.                     DrawGList(rpG,vP);
  4369.                     RemIBob(TheBob,rpG,vP);
  4370.                     SortGList(rpG);
  4371.                     DrawGList(rpG,vP);
  4372.                     MakeVPort(GfxBase->ActiView,vP);
  4373.                     MrgCop(GfxBase->ActiView);
  4374.             LoadBobImage(tmp1);
  4375.                     ClipBlitTrans (
  4376.             &(BobTransImage->ti_RP),    /* Source RastPort */
  4377.                  0, 0,        /* Source LeftEdge, TopEdge */
  4378.                  rpG,        /* Destination RastPort */
  4379.                  ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  4380.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  4381.                  BobTransImage->ti_IM->Height,/* Height of Image */
  4382.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  4383.                     BobVSprite->X = WIDTH-1-BOBWIDTH;
  4384.                     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4385.                     LoadBobImage(BLANKDATA);
  4386.                     AddBob(TheBob,rpG);
  4387.                     SortGList(rpG);
  4388.                     DrawGList(rpG,vP);
  4389.                     MakeVPort(GfxBase->ActiView,vP);
  4390.                     MrgCop(GfxBase->ActiView);
  4391.                    }
  4392.                   else
  4393.                   {
  4394.                    MouseDropped = 1;
  4395.             if (((piece == 'p')&&(DestRow == 7))||/* possible prom wht */
  4396.                        ((piece == 'P')&&(!DestRow))) /* possible blk promotion */
  4397.                      {
  4398.                       PromoteChar = DisplayPromoteRequestor();
  4399.                      }
  4400.                    tempstr[4] = 0;
  4401.                    tempstr[0] = OrigCol + 'a';
  4402.                    tempstr[1] = OrigRow + '1';
  4403.                    tempstr[2] = DestCol + 'a';
  4404.                    tempstr[3] = DestRow + '1';
  4405.                    mySetABPenDrMd(rpG,1,bpen,JAM1);
  4406.                    Move(rpG,520,USERBOX+6);
  4407.                    if (computer != black)
  4408.                     sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  4409.                    else
  4410.                     sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  4411.                    Text(rpG,mvnstr,strlen(mvnstr));
  4412.                    Text(rpG,tempstr,strlen(tempstr));
  4413.                   }
  4414.                  }
  4415.                }
  4416.               else if (class == INTUITICKS)
  4417.                {
  4418.                 BobVSprite->X = MouseX - 24;
  4419.                 BobVSprite->Y = MouseY - 16;
  4420.                 SortGList(rpG);
  4421.                 DrawGList(rpG,vP);
  4422.                 MakeVPort(GfxBase->ActiView,vP);
  4423.                 MrgCop(GfxBase->ActiView);
  4424.                }
  4425.                } /* ! done2 */
  4426.               }
  4427.              } /* signals & WINDOWSIGNAL */
  4428.             } while (!done2);
  4429.             ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags);
  4430.             while ( (message = (struct IntuiMessage *)
  4431.          GetMsg(wG->UserPort) ))
  4432.              {
  4433.           ReplyMsg((struct Message *)message);
  4434.              }
  4435.            }
  4436.          }
  4437.    }
  4438.   } /* while message */
  4439.   } /* signals & windowsignal */
  4440.   } while (!done);
  4441. OffMenu(wG,SHOWMENUNUM); 
  4442. OffMenu(wG,BOOKMENUNUM); 
  4443. OffMenu(wG,SUPERMENUNUM); 
  4444. OffMenu(wG,THINKMENUNUM); 
  4445. if (tempstr[2] == '-')
  4446.  {
  4447.   for(ilen=2;ilen<strlen(tempstr);ilen++)
  4448.    tempstr[ilen] = tempstr[ilen+1];
  4449.  }
  4450. if (tempstr[4] == '/')
  4451.  {
  4452.   for(ilen=4;ilen<strlen(tempstr);ilen++)
  4453.    tempstr[ilen] = tempstr[ilen+1];
  4454.  }
  4455. if ((!PromoteChar)&&((strlen(tempstr) == 2) || (strlen(tempstr) == 4)))
  4456.  {
  4457.   r = tempstr[1] - '1';
  4458.   if ((strlen(tempstr) == 2)&&(opponent == white))
  4459.    {
  4460.     r--;
  4461.    }
  4462.   else if ((strlen(tempstr) == 2)&&(opponent == black))
  4463.    {
  4464.     r++;
  4465.    }
  4466.   c = tempstr[0] - 'a';
  4467.   l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  4468.   if ((color[l] == neutral)||(opponent != color[l]))
  4469.    {
  4470.     done2 = 1;
  4471.    }
  4472.   else if (color[l] == white)
  4473.    piece = qxx[board[l]]; /* white are lower case pieces */
  4474.   else
  4475.    piece = pxx[board[l]]; /* black are upper case pieces */
  4476.   if (strlen(tempstr) == 4)
  4477.    {
  4478.      r = tempstr[3] - '1';
  4479.    }
  4480.   else
  4481.    {
  4482.     if (opponent == white)
  4483.      {
  4484.       r++;
  4485.      }
  4486.      else
  4487.      {
  4488.       r--;
  4489.      }
  4490.    }
  4491.   if (((piece == 'p')&&(r == 7))||/* possible prom wht */
  4492.       ((piece == 'P')&&(!r))) /* possible blk promotion */
  4493.     {
  4494.      PromoteChar = DisplayPromoteRequestor();
  4495.      if (strlen(tempstr) == 2)
  4496.       {
  4497.        if (!r)
  4498.         {
  4499.          tempstr[4] = 0;
  4500.          tempstr[3] = tempstr[1];
  4501.          tempstr[2] = tempstr[0];
  4502.          tempstr[1]++;
  4503.         }
  4504.        else
  4505.         {
  4506.          tempstr[4] = 0;
  4507.          tempstr[3] = tempstr[1];
  4508.          tempstr[2] = tempstr[0];
  4509.          tempstr[1]--;  
  4510.         }
  4511.       }
  4512.     }
  4513.  }
  4514. if (PromoteChar)
  4515.  {
  4516.   ilen = strlen(tempstr);
  4517.   tempstr[ilen] = PromoteChar;
  4518.   tempstr[ilen+1] = 0;
  4519.  }
  4520. strcpy(str,tempstr);
  4521. if (!(stricmp(str,"new")))
  4522.  {
  4523.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  4524.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4525.     LoadBobImage(BLANKDATA);
  4526.     SortGList(rpG);
  4527.     DrawGList(rpG,vP);
  4528.     MakeVPort(GfxBase->ActiView,vP);
  4529.     MrgCop(GfxBase->ActiView);
  4530.     WaitTOF();
  4531.     RethinkDisplay();
  4532.  }
  4533. }
  4534.  
  4535. void AnimateAmigaMove(str,piece)
  4536. char *str;
  4537. char piece; /* black are upper case pieces, white lower case */
  4538. {
  4539.  int side;
  4540.  int tmp1,tmp2;
  4541.  int srow,scol,erow,ecol,incrx,incry,i;
  4542.  long mpiece;
  4543.  
  4544.  
  4545.  mpiece = piece;
  4546.  if (!MouseDropped)
  4547.   {
  4548.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  4549.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4550.    LoadBobImage(BLANKDATA);
  4551.    SortGList(rpG);
  4552.    DrawGList(rpG,vP);
  4553.    MakeVPort(GfxBase->ActiView,vP);
  4554.    MrgCop(GfxBase->ActiView);
  4555.    scol = str[0] - 'a';
  4556.    srow = str[1] - '1';
  4557.    ecol = str[2] - 'a';
  4558.    erow = str[3] - '1';
  4559.    tmp1 = srow & 1;
  4560.    tmp2 = scol & 1;
  4561.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4562.     {
  4563.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  4564.         RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4565.         0xc0L,0xffL,0L);
  4566.     }
  4567.    else
  4568.     {
  4569.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  4570.         RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4571.         0xc0L,0xffL,0L);
  4572.     }
  4573.    tmp1 = erow & 1;
  4574.    tmp2 = ecol & 1;
  4575.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4576.     {
  4577.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[ecol],
  4578.         RowArray[erow],SQUAREWIDTH,SQUAREHEIGHT,
  4579.         0xc0L,0xffL,0L);
  4580.     }
  4581.    else
  4582.     {
  4583.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[ecol],
  4584.         RowArray[erow],SQUAREWIDTH,SQUAREHEIGHT,
  4585.         0xc0L,0xffL,0L);
  4586.     }
  4587.    BobVSprite->X = ColArray[scol];
  4588.    BobVSprite->Y = RowArray[srow];
  4589.    LoadBobImage(mpiece);
  4590.    SortGList(rpG);
  4591.    DrawGList(rpG,vP);
  4592.    MakeVPort(GfxBase->ActiView,vP);
  4593.    MrgCop(GfxBase->ActiView);
  4594.    incry = (RowArray[erow] - RowArray[srow])/8;
  4595.    incrx = (ColArray[ecol] - ColArray[scol])/8;
  4596.    for(i=0;i<8;i++)
  4597.     {
  4598.      BobVSprite->X += incrx;
  4599.      BobVSprite->Y += incry;
  4600.      SortGList(rpG);
  4601.      DrawGList(rpG,vP);
  4602.      MakeVPort(GfxBase->ActiView,vP);
  4603.      MrgCop(GfxBase->ActiView);
  4604.     }
  4605.    RemIBob(TheBob,rpG,vP);
  4606.    SortGList(rpG);
  4607.    DrawGList(rpG,vP);
  4608.    MakeVPort(GfxBase->ActiView,vP);
  4609.    MrgCop(GfxBase->ActiView);
  4610.    ClipBlitTrans (
  4611.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4612.              0, 0,        /* Source LeftEdge, TopEdge */
  4613.              rpG,        /* Destination RastPort */
  4614.              ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  4615.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4616.              BobTransImage->ti_IM->Height,/* Height of Image */
  4617.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4618.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  4619.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4620.    LoadBobImage(BLANKDATA);
  4621.    AddBob(TheBob,rpG);
  4622.    MakeVPort(GfxBase->ActiView,vP);
  4623.    MrgCop(GfxBase->ActiView);
  4624.    if (piece >= 'a')
  4625.     {
  4626.      mpiece = 'r';
  4627.      srow = 0;
  4628.      erow = 0;
  4629.      side = white;
  4630.      if (str[2] == 'g') /* king side white */
  4631.       {
  4632.        scol = 7;
  4633.        ecol = 5;
  4634.       }
  4635.      else
  4636.       {
  4637.        ecol = 3;
  4638.        scol = 0;
  4639.       }
  4640.     }
  4641.    else
  4642.     {
  4643.      mpiece = 'R';
  4644.      srow = 7;
  4645.      erow = 7;
  4646.      side = black;
  4647.      if (str[2] == 'g') /* king side black */
  4648.       {
  4649.        scol = 7;
  4650.        ecol = 5;
  4651.       }
  4652.      else
  4653.       {
  4654.        ecol = 3;
  4655.        scol = 0;
  4656.       }
  4657.     }
  4658.    if (Castled[side])
  4659.     {
  4660.      Castled[side] = 0;
  4661.      tmp1 = srow & 1;
  4662.      tmp2 = scol & 1;
  4663.      if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4664.       {
  4665.        BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  4666.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4667.             0xc0L,0xffL,0L);
  4668.       }
  4669.      else
  4670.       {
  4671.        BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  4672.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4673.             0xc0L,0xffL,0L);
  4674.       }
  4675.      BobVSprite->X = ColArray[scol];
  4676.      BobVSprite->Y = RowArray[srow];
  4677.      SortGList(rpG);
  4678.      DrawGList(rpG,vP);
  4679.      MakeVPort(GfxBase->ActiView,vP);
  4680.      MrgCop(GfxBase->ActiView);
  4681.      LoadBobImage(mpiece);
  4682.      SortGList(rpG);
  4683.      DrawGList(rpG,vP);
  4684.      MakeVPort(GfxBase->ActiView,vP);
  4685.      MrgCop(GfxBase->ActiView);
  4686.      incry = (RowArray[erow] - RowArray[srow])/8;
  4687.      incrx = (ColArray[ecol] - ColArray[scol])/8;
  4688.      for(i=0;i<8;i++)
  4689.       {
  4690.        BobVSprite->X += incrx;
  4691.        BobVSprite->Y += incry;
  4692.        SortGList(rpG);
  4693.        DrawGList(rpG,vP);
  4694.        MakeVPort(GfxBase->ActiView,vP);
  4695.        MrgCop(GfxBase->ActiView);
  4696.       }
  4697.      RemIBob(TheBob,rpG,vP);
  4698.      SortGList(rpG);
  4699.      DrawGList(rpG,vP);
  4700.      MakeVPort(GfxBase->ActiView,vP);
  4701.      MrgCop(GfxBase->ActiView);
  4702.      ClipBlitTrans (
  4703.             &(BobTransImage->ti_RP),    /* Source RastPort */
  4704.                  0, 0,        /* Source LeftEdge, TopEdge */
  4705.                  rpG,        /* Destination RastPort */
  4706.                  ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  4707.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  4708.                  BobTransImage->ti_IM->Height,/* Height of Image */
  4709.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  4710.      LoadBobImage(BLANKDATA);
  4711.      AddBob(TheBob,rpG);
  4712.      MakeVPort(GfxBase->ActiView,vP);
  4713.      MrgCop(GfxBase->ActiView);
  4714.     }
  4715.    else /* check EnPassant */
  4716.     {
  4717.      side ^= 1;
  4718.      if (myEnPassant[side])
  4719.       {
  4720.        myEnPassant[side] = 0;
  4721.        scol = str[2] - 'a';
  4722.        if (str[3] == '3') /* white is removed from bd at 4*/
  4723.         {
  4724.          srow = 3;
  4725.         }
  4726.        else /* black is removed at pos 5 */
  4727.         {
  4728.          srow = 4;
  4729.         }
  4730.        tmp1 = srow & 1;
  4731.        tmp2 = scol & 1;
  4732.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4733.         {
  4734.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  4735.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4736.             0xc0L,0xffL,0L);
  4737.         }
  4738.        else
  4739.         {
  4740.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  4741.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4742.             0xc0L,0xffL,0L);
  4743.         }
  4744.       }
  4745.     }
  4746.   }
  4747. }
  4748.  
  4749. #endif /* AMIGA */
  4750.  
  4751.  
  4752. void GetTimeString(str)
  4753. char *str;
  4754. {
  4755. #ifdef AMIGA
  4756. #endif
  4757. }
  4758.  
  4759.  
  4760.  
  4761. char __aligned *ColorStr[2];
  4762. char __far __aligned *CP[CPSIZE];
  4763. /*
  4764.  * In a networked enviroment gnuchess might be compiled on different hosts
  4765.  * with different random number generators, that is not acceptable if they
  4766.  * are going to share the same transposition table.
  4767.  */
  4768.  
  4769. unsigned int
  4770. urand (void)
  4771. {
  4772.   next *= 1103515245;
  4773.   next += 12345;
  4774.   return ((unsigned int) (next >> 16) & 0xFFFF);
  4775. }
  4776.  
  4777.  
  4778. unsigned long __aligned hashkey, hashbd;
  4779. #ifdef LONGINTS2
  4780. struct hashval __far hashcode[2][7][64];
  4781. #else
  4782. struct hashval __aligned hashcode[2][7][64];
  4783. #endif
  4784.  
  4785. #ifdef CACHE
  4786. #ifdef ttblsz
  4787. struct hashentry huge __aligned *ttable[2];
  4788. unsigned int __aligned ttblsize;
  4789. #endif
  4790.  
  4791. #else
  4792.  
  4793. #ifdef ttblsz
  4794. struct hashentry __aligned __far ttable[2][vttblsz + MAXrehash];
  4795. unsigned int __aligned ttblsize;
  4796. #endif
  4797.  
  4798. #endif
  4799.  
  4800. char __far __aligned savefile[128] = "";
  4801. char __far __aligned listfile[128] = "";
  4802. #ifdef HISTORY
  4803. unsigned char __far __aligned history[32768];
  4804. #endif
  4805. INTSIZE __aligned rpthash[2][256];
  4806. struct leaf __far __aligned Tree[TREE];
  4807. struct leaf  __aligned *root;
  4808. INTSIZE __aligned TrPnt[MAXDEPTH];
  4809. INTSIZE __aligned PieceList[2][64], PawnCnt[2][8];
  4810. INTSIZE __aligned castld[2], Mvboard[64];
  4811. INTSIZE __aligned svalue[64];
  4812. struct flags __aligned flag;
  4813. INTSIZE __aligned opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither, INCscore;
  4814. long __aligned ResponseTime, ExtraTime, MaxResponseTime, et, et0, time0, ft;
  4815. long __aligned GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol,
  4816.  THashCol, filesz;
  4817. long __aligned replus, reminus;
  4818. INTSIZE __aligned HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
  4819. INTSIZE __aligned player, xwndw, rehash;
  4820. struct GameRec __aligned GameList[MAXMOVES + MAXDEPTH];
  4821. INTSIZE __aligned Sdepth, GameCnt, Game50, MaxSearchDepth;
  4822. INTSIZE __aligned epsquare, contempt;
  4823. int __aligned Book;
  4824. struct TimeControlRec __aligned TimeControl;
  4825. INTSIZE __aligned TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
  4826. INTSIZE __aligned XCmoves[3], XCminutes[3], XCseconds[3], XC, XCmore;
  4827. const INTSIZE __aligned otherside[3] =
  4828. {black, white, neutral};
  4829. unsigned INTSIZE __aligned hint;
  4830. INTSIZE int __aligned TOflag;        /* force search re-init if we backup search */
  4831.  
  4832. INTSIZE __aligned mtl[2], pmtl[2], hung[2];
  4833. INTSIZE __aligned Pindex[64];
  4834. INTSIZE __aligned PieceCnt[2];
  4835. INTSIZE __aligned FROMsquare, TOsquare;
  4836. INTSIZE __aligned HasKnight[2], HasBishop[2], HasRook[2], HasQueen[2];
  4837. INTSIZE __aligned ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], PawnThreat[MAXDEPTH];
  4838. INTSIZE __aligned Pscore[MAXDEPTH], Tscore[MAXDEPTH];
  4839. const INTSIZE __aligned qrook[3] =
  4840. {0, 56, 0};
  4841. const INTSIZE __aligned krook[3] =
  4842. {7, 63, 0};
  4843. const INTSIZE __aligned kingP[3] =
  4844. {4, 60, 0};
  4845. const INTSIZE __aligned rank7[3] =
  4846. {6, 1, 0};
  4847. const INTSIZE __aligned sweep[8] =
  4848. {false, false, false, true, true, true, false, false};
  4849. unsigned INTSIZE __aligned killr0[MAXDEPTH], killr1[MAXDEPTH];
  4850. unsigned INTSIZE __aligned killr2[MAXDEPTH], killr3[MAXDEPTH];
  4851. unsigned INTSIZE __aligned PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit;
  4852. #ifdef KILLT
  4853. INTSIZE __far __aligned killt[0x4000];
  4854. #endif
  4855. const INTSIZE __aligned value[7] =
  4856. {0, valueP, valueN, valueB, valueR, valueQ, valueK};
  4857. const INTSIZE __aligned control[7] =
  4858. {0, ctlP, ctlN, ctlB, ctlR, ctlQ, ctlK};
  4859. INTSIZE __aligned stage, stage2, Developed[2];
  4860. FILE __aligned *hashfile;
  4861. unsigned int __aligned starttime;
  4862. INTSIZE int __aligned ahead = true, hash = true;
  4863.  
  4864. #if defined CHESSTOOL || defined XBOARD
  4865. void
  4866. TerminateChess (int sig)
  4867. {
  4868.   ExitChess();
  4869. }
  4870. #endif
  4871.  
  4872. int __aligned timeopp[MINGAMEIN], timecomp[MINGAMEIN];
  4873. int __aligned compptr, oppptr;
  4874.  
  4875. inline void
  4876. TimeCalc ()
  4877. {
  4878. /* adjust number of moves remaining in gamein games */
  4879.   int increment = 0;
  4880.   int topsum = 0;
  4881.   int tcompsum = 0;
  4882.   int me,him;
  4883.   int i;
  4884. /* dont do anything til you have enough numbers */
  4885.   if (GameCnt < (MINGAMEIN * 2)) return;
  4886. /* calculate average time in sec for last MINGAMEIN moves */
  4887.   for (i = 0; i < MINGAMEIN; i++)
  4888.     {
  4889.       tcompsum += timecomp[i];
  4890.       topsum += timeopp[i];
  4891.     }
  4892.   topsum /= (100 * MINGAMEIN);
  4893.   tcompsum /= (100 * MINGAMEIN);
  4894. /* if I have less time than opponent add another move */
  4895.     me = TimeControl.clock[computer]/100; 
  4896.     him = TimeControl.clock[opponent]/100;
  4897.     if(me < him) increment += 2;
  4898. /* if I am losing more time with each move add another */
  4899.   /*if ( !((me - him) > 60) && tcompsum > topsum) increment++;*/
  4900.   if ( tcompsum > topsum) increment +=2;
  4901. /* but dont let moves go below MINMOVES */
  4902.   else if (TimeControl.moves[computer] < MINMOVES && !increment) increment++;
  4903. /* if I am doing really well use more time per move */
  4904.   else if (me > him && tcompsum < topsum) increment = -1;
  4905.   TimeControl.moves[computer] += increment;
  4906. }
  4907.  
  4908.  
  4909. /* hmm.... shouldn`t main be moved to the interface routines */
  4910. int
  4911. main (int aargc, char **aargv)
  4912. {
  4913.   char cstring[40];
  4914.   char *xwin = 0;
  4915.   char *Lang = NULL;
  4916.  
  4917. #ifdef AMIGA
  4918.  int tmpargcnt;
  4919.  struct WBStartup *startmsg;
  4920.  struct ExecBase **execbaseptr=(struct ExecBase **)4L;
  4921.  UWORD cpuid;
  4922.  struct ExecBase *execbase;
  4923.  BPTR fp;
  4924.  APTR tempxx;
  4925.  struct WBArg *mywbptr;
  4926.  struct DiskObject *dob;
  4927.  
  4928.  execbase = *execbaseptr;
  4929.  cpuid = execbase->AttnFlags;
  4930.  
  4931.  if (!(cpuid & AFF_68020))
  4932.   {
  4933.    exit(0);
  4934.   }
  4935.  gfxversion = GfxBase->LibNode.lib_Version;
  4936.  if (gfxversion < 37)
  4937.   exit(-1);
  4938.  if (!aargc)
  4939.   {
  4940.    startmsg = (struct WBStartup *)aargv;
  4941.    mywbptr = startmsg->sm_ArgList; 
  4942.    if (dob = GetDiskObject (mywbptr->wa_Name))
  4943.     {
  4944.      xwin = FindToolType(dob->do_ToolTypes,"PRI");
  4945.      if (xwin)
  4946.       {
  4947.        procpri = xwin[0] - '0';
  4948.        if (procpri < 0)
  4949.         procpri = 0;
  4950.        if (procpri > 4)
  4951.         procpri = 4;
  4952.       }
  4953.      xwin = FindToolType(dob->do_ToolTypes,"COLORS");
  4954.      if (xwin)
  4955.       {
  4956.        if ((xwin[0] == '1')&&(xwin[1] == '6'))
  4957.         gfxversion = 37;
  4958.        else if ((xwin[0] == '6')&&(xwin[1] == '4'))
  4959.         FasterDisplay = 1;
  4960.       }
  4961.      xwin = FindToolType(dob->do_ToolTypes,"MONITOR");
  4962.      if (xwin)
  4963.       {
  4964.        if ((xwin[0] == '1')&&(xwin[1] == '5'))
  4965.         v15Khz = 1;
  4966.       }
  4967.      xwin = FindToolType(dob->do_ToolTypes,"FASTAGA");
  4968.      if (xwin)
  4969.       {
  4970.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  4971.         FasterDisplay = 1;
  4972.       }
  4973.      xwin = FindToolType(dob->do_ToolTypes,"SUPER72");
  4974.      if (xwin)
  4975.       {
  4976.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  4977.         Super72 = 1;
  4978.       }
  4979.      FreeDiskObject (dob);
  4980.     }
  4981.    xwin = 0L;
  4982.   }
  4983.  else if (aargc > 1)
  4984.   {
  4985.    for(tmpargcnt=1;tmpargcnt<aargc;tmpargcnt++)
  4986.     {
  4987.      if (!(strcmp(aargv[tmpargcnt],"16")))
  4988.       {
  4989.        gfxversion = 37;
  4990.       }
  4991.      else if (!(stricmp(aargv[tmpargcnt],"Super72")))
  4992.       {
  4993.        Super72 = 1;
  4994.       }
  4995.      else if (!(stricmp(aargv[tmpargcnt],"15KHZ")))
  4996.       {
  4997.        v15Khz = 1;
  4998.       }
  4999.      else if ((!(stricmp(aargv[tmpargcnt],"FASTAGA")))||((!(strcmp(aargv[tmpargcnt],"64")))))
  5000.       {
  5001.        FasterDisplay = 1;
  5002.       }
  5003.      else if (strcmp(aargv[tmpargcnt],"256"))
  5004.       {
  5005.        procpri=atoi(aargv[tmpargcnt]);
  5006.        if (procpri < 0)
  5007.          procpri = 0;
  5008.        if (procpri > 4)
  5009.         procpri = 4;
  5010.       }
  5011.     }
  5012.   }
  5013.  if (gfxversion < 39)
  5014.   Super72 = 0;
  5015.  Delay(3L);
  5016.  myproc = (struct Process *)FindTask(0L);
  5017.  tempxx = myproc->pr_WindowPtr;
  5018.  Delay(3L);
  5019.  myproc->pr_WindowPtr = (APTR)-1L;
  5020.  if (!(fp = Open("uchess:uchess.lang",MODE_OLDFILE)))
  5021.   {
  5022.    system("Assign >nil: uchess: \"\"");
  5023.   }
  5024.  else
  5025.   Close(fp);
  5026.  myproc->pr_WindowPtr = tempxx;
  5027. #endif
  5028.  
  5029.   
  5030.   gsrand (starttime = ((unsigned int) time ((long *) 0)));    /* init urand */
  5031. #ifdef ttblsz
  5032.   ttblsize = ttblsz;
  5033.   rehash = -1;
  5034. #endif /* ttblsz */
  5035.   flag.easy = 0;
  5036. #ifndef AMIGA
  5037.   if (argc > 2)
  5038.     {
  5039.       if (argv[1][0] == '-' && argv[1][1] == 'L')
  5040.     {
  5041.       Lang = argv[2];
  5042.       argv += 2;
  5043.       argc -= 2;
  5044.     }
  5045.     }
  5046. #endif
  5047.   InitConst (Lang);
  5048.   ColorStr[0] = CP[118];
  5049.   ColorStr[1] = CP[119];
  5050.  
  5051. #ifndef AMIGA
  5052.   while (argc > 1 && ((argv[1][0] == '-') || (argv[1][0] == '+')))
  5053.     {
  5054.       switch (argv[1][1])
  5055.     {
  5056.     case 'a':
  5057.       ahead = ((argv[1][0] == '-') ? false : true);
  5058.       break;
  5059.     case 'h':
  5060.       hash = ((argv[1][0] == '-') ? false : true);
  5061.       break;
  5062.     case 's':
  5063.       argc--;
  5064.       argv++;
  5065.       if (argc > 1)
  5066.         strcpy (savefile, argv[1]);
  5067.       break;
  5068.     case 'l':
  5069.       argc--;
  5070.       argv++;
  5071.       if (argc > 1)
  5072.         strcpy (listfile, argv[1]);
  5073.       break;
  5074.  
  5075. #if ttblsz
  5076.     case 'r':
  5077.       if (argc > 2)
  5078.         rehash = atoi (argv[2]);
  5079.       argc--;
  5080.       argv++;
  5081.       if (rehash > MAXrehash)
  5082.         rehash = MAXrehash;
  5083.       break;
  5084.     case 'T':
  5085.       if (argc > 2)
  5086.         ttblsize = atoi (argv[2]);
  5087.       argc--;
  5088.       argv++;
  5089.       if (ttblsize > 0 && ttblsize < 24)
  5090.         ttblsize = (1 << ttblsize);
  5091.       else
  5092.         ttblsize = ttblsz;
  5093.       break;
  5094. #ifdef HASHFILE
  5095.     case 't':        /* create or test persistent transposition
  5096.                  * table */
  5097.       hashfile = fopen (HASHFILE, RWA_ACC);
  5098.       if (hashfile)
  5099.         {
  5100.           fseek (hashfile, 0L, SEEK_END);
  5101.           filesz = (ftell (hashfile) / sizeof (struct fileentry)) - 1;
  5102.         }
  5103.       if (hashfile != NULL)
  5104.         {
  5105.           long i, j;
  5106.           int nr[MAXDEPTH];
  5107.           struct fileentry n;
  5108.  
  5109.           /*ShowMessage (CP[49]);*/
  5110.           for (i = 0; i < MAXDEPTH; i++)
  5111.         nr[i] = 0;
  5112.           fseek (hashfile, 0L, SEEK_END);
  5113.           i = ftell (hashfile) / sizeof (struct fileentry);
  5114.           fseek (hashfile, 0L, SEEK_SET);
  5115.           for (j = 0; j < i + 1; j++)
  5116.         {
  5117.           fread (&n, sizeof (struct fileentry), 1, hashfile);
  5118.           if (n.depth)
  5119.             {
  5120.               nr[n.depth]++;
  5121.               nr[0]++;
  5122.             }
  5123.         }
  5124.           sprintf (astr,CP[109],
  5125.               nr[0], i);
  5126.               /*ShowMessage(astr);*/
  5127.           for (j = 1; j < MAXDEPTH; j++)
  5128.                /*
  5129.         printf ("%d ", nr[j]);
  5130.           printf ("\n")*/;
  5131.         }
  5132.       return 0;
  5133.     case 'c':        /* create or test persistent transposition
  5134.                  * table */
  5135.       if (argc > 2)
  5136.         filesz = atoi (argv[2]);
  5137.       if (filesz > 0 && filesz < 24)
  5138.         filesz = (1 << filesz) - 1 + MAXrehash;
  5139.       else
  5140.         filesz = Deffilesz + MAXrehash;
  5141.       if ((hashfile = fopen (HASHFILE, RWA_ACC)) == NULL)
  5142.         hashfile = fopen (HASHFILE, WA_ACC);
  5143.       if (hashfile != NULL)
  5144.         {
  5145.           long j;
  5146.           struct fileentry n;
  5147.  
  5148.           /*printf (CP[66]);*/
  5149.           for (j = 0; j < 32; j++)
  5150.         n.bd[j] = 0;
  5151.           n.f = n.t = 0;
  5152.           n.flags = 0;
  5153.           n.depth = 0;
  5154.           n.sh = n.sl = 0;
  5155.           for (j = 0; j < filesz + 1; j++)
  5156.         fwrite (&n, sizeof (struct fileentry), 1, hashfile);
  5157.           fclose (hashfile);
  5158.         }
  5159.      /* else
  5160.         printf (CP[50], HASHFILE);*/
  5161.       return (0);
  5162. #endif /* HASHFILE */
  5163. #endif /* ttblsz */
  5164.     case 'x':
  5165.       xwin = &argv[1][2];
  5166.       break;
  5167.     case 'v':
  5168. /*      fprintf (stderr, CP[102], version, patchlevel);*/
  5169.       exit (1);
  5170.     default:
  5171.       /*fprintf (stderr, CP[113]);*/
  5172.       exit (1);
  5173.     }
  5174.       argv++;
  5175.       argc--;
  5176.     }
  5177. #endif
  5178.   XC = 0;
  5179.   MaxResponseTime = 0;
  5180. #if defined CHESSTOOL || defined XBOARD
  5181.   signal (SIGTERM, TerminateChess);
  5182.   TCflag = true;
  5183.   TCmoves = 40;
  5184.   TCminutes = 120;
  5185.   TCseconds = 0;
  5186.   TCadd = 0;
  5187.   OperatorTime = 0;
  5188. #else
  5189. /*  TCflag = false;*/
  5190. /*  OperatorTime = 0;*/
  5191.   TCflag = true;
  5192.   TCmoves = 60;
  5193.   TCminutes = 10;
  5194.   TCseconds = 0;
  5195.   OperatorTime = 0;
  5196. #endif
  5197. #ifndef AMIGA
  5198.   if (argc == 2)
  5199.     {
  5200.       char *p;
  5201.  
  5202.       MaxResponseTime = 100L*strtol(argv[1], &p, 10);
  5203.       if (*p == ':')
  5204.     MaxResponseTime = 60L*MaxResponseTime + 
  5205.         100L*strtol(++p, (char **) NULL, 10);
  5206.       TCflag = false;
  5207.       TCmoves = 0;
  5208.       TCminutes = 0;
  5209.       TCseconds = 0;
  5210.     }
  5211.   if (argc >= 3)
  5212.     {
  5213.       char *p;
  5214.       if (argc > 9)
  5215.     {
  5216.      /* printf ("%s\n", CP[220]);*/
  5217.       exit (1);
  5218.     }
  5219.       TCmoves = atoi (argv[1]);
  5220.       TCminutes = strtol (argv[2], &p, 10);
  5221.       if (*p == ':')
  5222.     TCseconds = strtol (p + 1, (char **) NULL, 10);
  5223.       else
  5224.     TCseconds = 0;
  5225.       TCflag = true;
  5226.       argc -= 3;
  5227.       argv += 3;
  5228.       while (argc > 1)
  5229.     {
  5230.       XCmoves[XC] = atoi (argv[0]);
  5231.       XCminutes[XC] = strtol (argv[1], &p, 10);
  5232.       if (*p == ':')
  5233.         XCseconds[XC] = strtol (p + 1, (char **) NULL, 10);
  5234.       else
  5235.         XCseconds[XC] = 0;
  5236.       if (XCmoves[XC] && (XCminutes[XC] || XCseconds[XC]))
  5237.         XC++;
  5238.       else
  5239.         {
  5240.           /*printf (CP[220]);*/
  5241.           exit (1);
  5242.         }
  5243.       argc -= 2;
  5244.       argv += 2;
  5245.     }
  5246.       if (argc)
  5247.     {
  5248.       /*printf ("%s\n", CP[220]);*/
  5249.       exit (1);
  5250.     }
  5251.     }
  5252. #endif /* AMIGA */
  5253. #ifdef AMIGA
  5254.  if (!AmigaStartup())
  5255.   {
  5256.    exit(2);
  5257.   }
  5258. #endif
  5259.   Initialize ();
  5260. #ifndef CACHE
  5261. #ifdef ttblsz
  5262.   Initialize_ttable ();
  5263. #endif /* ttblsz */
  5264. #endif
  5265.   Initialize_dist ();
  5266.   Initialize_moves ();
  5267.   FirstTime = 1;
  5268.   NewGame ();
  5269.   flag.easy = ahead;
  5270.   flag.hash = hash;
  5271.   if (xwin)
  5272.     xwndw = atoi (xwin);
  5273.  
  5274.   hashfile = NULL;
  5275. #if ttblsz
  5276. #ifdef HASHFILE
  5277.   hashfile = fopen (HASHFILE, RWA_ACC);
  5278.   if (hashfile)
  5279.     {
  5280.       fseek (hashfile, 0L, SEEK_END);
  5281.       filesz = ftell (hashfile) / sizeof (struct fileentry) - 1;
  5282.     }
  5283. #if !defined CHESSTOOL && !defined XBOARD
  5284.   else
  5285.     ShowMessage (CP[98]);
  5286. #endif
  5287. #endif /* HASHFILE */
  5288. #endif /* ttblsz */
  5289. #ifdef AMIGA
  5290.  (void)SetTaskPri((struct Task *)myproc,procpri);
  5291.  Delay(3L);
  5292.  SetMenuStrip(wG,&MenuList1);    /* attach any Menu */
  5293.  MenuStripSet = 1;
  5294. #endif
  5295.   while (!(flag.quit))
  5296.     {
  5297.       oppptr = (oppptr + 1) % MINGAMEIN;
  5298.       if (flag.bothsides && !flag.mate)
  5299.        {
  5300.         SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  5301.     SelectMove (opponent, 1);
  5302.        }
  5303.       else
  5304.         {
  5305.       InputCommand (cstring);
  5306.         }
  5307.  
  5308.       if (opponent == black)
  5309.     if (flag.gamein || TCadd)
  5310.       {
  5311.         TimeCalc ();
  5312.       }
  5313.     else if (TimeControl.moves[opponent] == 0)
  5314.       {
  5315.         if (XC)
  5316.           if (XCmore < XC)
  5317.         {
  5318.           TCmoves = XCmoves[XCmore];
  5319.           TCminutes = XCminutes[XCmore];
  5320.           TCseconds = XCseconds[XCmore];
  5321.           XCmore++;
  5322.         }
  5323.         SetTimeControl ();
  5324.       }
  5325.  
  5326.       compptr = (compptr + 1) % MINGAMEIN;
  5327.  
  5328.  
  5329.       if (SupervisorMode)
  5330.        {
  5331.       computer = computer ^ 1;
  5332.       opponent = opponent ^ 1;
  5333.       xwndw = (computer == white) ? WXWNDW : BXWNDW;
  5334.       flag.force = false;
  5335.       Sdepth = 0;
  5336.        }
  5337.       else if (!(flag.quit || flag.mate || flag.force))
  5338.     {
  5339.           SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  5340.       SelectMove (computer, 1);
  5341.       if (computer == black)
  5342.         if (flag.gamein)
  5343.           {
  5344.         TimeCalc ();
  5345.           }
  5346.         else if (TimeControl.moves[computer] == 0)
  5347.           {
  5348.         if (XC)
  5349.           if (XCmore < XC)
  5350.             {
  5351.               TCmoves = XCmoves[XCmore];
  5352.               TCminutes = XCminutes[XCmore];
  5353.               TCseconds = XCseconds[XCmore];
  5354.               XCmore++;
  5355.             }
  5356.         SetTimeControl ();
  5357.           }
  5358.     }
  5359.       if ((flag.mate)&&(!Mate)&&(!DrawnGame))
  5360.        ShowMessage("CheckMate");
  5361.       if (Mate)
  5362.        {
  5363.         ShowMessage(MateString);
  5364.        }
  5365.       else if (DrawnGame)
  5366.        {
  5367.         ShowMessage("Draw..");
  5368.        }
  5369.       else if ((!flag.mate)&&(PlayMode == 2)&&(!ResignOffered)&&(!flag.quit))
  5370.        {
  5371.         if (global_tmp_score < -950)
  5372.          {
  5373.           if (DoResign())
  5374.            {
  5375.             flag.mate = true;
  5376.             Mate = 1;
  5377.             ShowMessage("You Win!");
  5378.             ShowMessage("UChess Resigns");
  5379.            }
  5380.          }
  5381.        }
  5382.     }
  5383. #if ttblsz
  5384. #ifdef HASHFILE
  5385.   if (hashfile)
  5386.     fclose (hashfile);
  5387. #endif /* HASHFILE */
  5388. #endif /* ttblsz */
  5389.  
  5390.   ExitChess ();
  5391. }
  5392.